config/html-elements-plugin/index.js
function createTag(tagName, attrMap, publicPath) {
  publicPath = publicPath || '';

  // add trailing slash if we have a publicPath and it doesn't have one.
  if (publicPath && !RE_ENDS_WITH_BS.test(publicPath)) {
    publicPath += '/';
  }

  const attributes = Object.getOwnPropertyNames(attrMap)
    .filter(function(name) { return name[0] !== '='; } )
    .map(function(name) {
      var value = attrMap[name];

      if (publicPath) {
        // check if we have explicit instruction, use it if so (e.g: =herf: false)
        // if no instruction, use public path if it's href attribute.
        const usePublicPath = attrMap.hasOwnProperty('=' + name) ? !!attrMap['=' + name] : name === 'href';

        if (usePublicPath) {
          // remove a starting trailing slash if the value has one so we wont have //
          value = publicPath + (value[0] === '/' ? value.substr(1) : value);
        }
      }

      return `${name}="${value}"`;
    });

  const closingTag = tagName === 'script' ? '</script>' : '';

  return `<${tagName} ${attributes.join(' ')}>${closingTag}`;
}
function createTag(tagName, attrMap, publicPath) {
  publicPath = publicPath || '';

  // add trailing slash if we have a publicPath and it doesn't have one.
  if (publicPath && !RE_ENDS_WITH_BS.test(publicPath)) {
    publicPath += '/';
  }

  const attributes = Object.getOwnPropertyNames(attrMap)
    .filter(function(name) { return name[0] !== '='; } )
    .map(function(name) {
      var value = attrMap[name];

      if (publicPath) {
        // check if we have explicit instruction, use it if so (e.g: =herf: false)
        // if no instruction, use public path if it's href attribute.
        const usePublicPath = attrMap.hasOwnProperty('=' + name) ? !!attrMap['=' + name] : name === 'href';

        if (usePublicPath) {
          // remove a starting trailing slash if the value has one so we wont have //
          value = publicPath + (value[0] === '/' ? value.substr(1) : value);
        }
      }

      return `${name}="${value}"`;
    });

  const closingTag = tagName === 'script' ? '</script>' : '';

  return `<${tagName} ${attributes.join(' ')}>${closingTag}`;
}
function createTag ( tagName , attrMap , publicPath ) { publicPath = publicPath || '' ; // add trailing slash if we have a publicPath and it doesn't have one. if ( publicPath && ! RE_ENDS_WITH_BS . test ( publicPath ) ) { publicPath += '/' ; } const attributes = Object . getOwnPropertyNames ( attrMap ) . filter ( function ( name ) { return name [ 0 ] !== '=' ; } ) . map ( function ( name ) { var value = attrMap [ name ] ; if ( publicPath ) { // check if we have explicit instruction, use it if so (e.g: =herf: false) // if no instruction, use public path if it's href attribute. const usePublicPath = attrMap . hasOwnProperty ( '=' + name ) ? ! ! attrMap [ '=' + name ] : name === 'href' ; if ( usePublicPath ) { // remove a starting trailing slash if the value has one so we wont have // value = publicPath + ( value [ 0 ] === '/' ? value . substr ( 1 ) : value ) ; } } return ` ${ name } ${ value } ` ; } ) ; const closingTag = tagName === 'script' ? '</script>' : '' ; return ` ${ tagName } ${ attributes . join ( ' ' ) } ${ closingTag } ` ; }
Create an HTML tag with attributes from a map.

Example:
createTag('link', { rel: "manifest", href: "/assets/manifest.json" })
// <link rel="manifest" href="/assets/manifest.json">
@param tagName The name of the tag
@param attrMap A Map of attribute names (keys) and their values.
@param publicPath a path to add to eh start of static asset url
@returns {string}
Create an HTML tag with attributes from a map .