create-html.js 612 B

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