create-html.js 507 B

12345678910111213
  1. var requireObjectCoercible = require('../internals/require-object-coercible');
  2. var toString = require('../internals/to-string');
  3. var quot = /"/g;
  4. // `CreateHTML` abstract operation
  5. // https://tc39.es/ecma262/#sec-createhtml
  6. module.exports = function (string, tag, attribute, value) {
  7. var S = toString(requireObjectCoercible(string));
  8. var p1 = '<' + tag;
  9. if (attribute !== '') p1 += ' ' + attribute + '="' + toString(value).replace(quot, '&quot;') + '"';
  10. return p1 + '>' + S + '</' + tag + '>';
  11. };