Files
codeql-action/node_modules/es-abstract/2018/CreateHTML.js
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

28 lines
846 B
JavaScript
Raw Normal View History

2020-09-14 10:42:37 +01:00
'use strict';
2024-09-16 17:29:58 +00:00
var $TypeError = require('es-errors/type');
2020-09-14 10:42:37 +01:00
2021-07-27 16:54:26 +00:00
var callBound = require('call-bind/callBound');
2020-09-14 10:42:37 +01:00
var $replace = callBound('String.prototype.replace');
var RequireObjectCoercible = require('./RequireObjectCoercible');
var ToString = require('./ToString');
2023-08-01 03:35:02 -07:00
// https://262.ecma-international.org/6.0/#sec-createhtml
2020-09-14 10:42:37 +01:00
module.exports = function CreateHTML(string, tag, attribute, value) {
2024-09-16 17:29:58 +00:00
if (typeof tag !== 'string' || typeof attribute !== 'string') {
2020-09-14 10:42:37 +01:00
throw new $TypeError('Assertion failed: `tag` and `attribute` must be strings');
}
var str = RequireObjectCoercible(string);
var S = ToString(str);
var p1 = '<' + tag;
if (attribute !== '') {
var V = ToString(value);
var escapedV = $replace(V, /\x22/g, '&quot;');
p1 += '\x20' + attribute + '\x3D\x22' + escapedV + '\x22';
}
return p1 + '>' + S + '</' + tag + '>';
};