main
Last change
on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
846 bytes
|
Line | |
---|
1 | 'use strict';
|
---|
2 |
|
---|
3 | var $TypeError = require('es-errors/type');
|
---|
4 |
|
---|
5 | var callBound = require('call-bind/callBound');
|
---|
6 |
|
---|
7 | var $replace = callBound('String.prototype.replace');
|
---|
8 |
|
---|
9 | var RequireObjectCoercible = require('./RequireObjectCoercible');
|
---|
10 | var ToString = require('./ToString');
|
---|
11 |
|
---|
12 | // https://262.ecma-international.org/6.0/#sec-createhtml
|
---|
13 |
|
---|
14 | module.exports = function CreateHTML(string, tag, attribute, value) {
|
---|
15 | if (typeof tag !== 'string' || typeof attribute !== 'string') {
|
---|
16 | throw new $TypeError('Assertion failed: `tag` and `attribute` must be strings');
|
---|
17 | }
|
---|
18 | var str = RequireObjectCoercible(string);
|
---|
19 | var S = ToString(str);
|
---|
20 | var p1 = '<' + tag;
|
---|
21 | if (attribute !== '') {
|
---|
22 | var V = ToString(value);
|
---|
23 | var escapedV = $replace(V, /\x22/g, '"');
|
---|
24 | p1 += '\x20' + attribute + '\x3D\x22' + escapedV + '\x22';
|
---|
25 | }
|
---|
26 | return p1 + '>' + S + '</' + tag + '>';
|
---|
27 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.