⌈⌋ ⎇ branch:  Bitrhythm


Hex Artifact Content

Artifact dc0e431a31a900f7a0a5d0d091b5eb0ddda65f540ab0453990225e978fb31ddf:


0000: 69 6d 70 6f 72 74 20 6d 61 6b 65 45 6c 65 6d 65  import makeEleme
0010: 6e 74 20 66 72 6f 6d 20 27 2e 2f 2e 2e 2f 63 6f  nt from './../co
0020: 6d 6d 6f 6e 2f 75 74 69 6c 2f 64 6f 6d 2f 6d 61  mmon/util/dom/ma
0030: 6b 65 2d 65 6c 65 6d 65 6e 74 27 0a 69 6d 70 6f  ke-element'.impo
0040: 72 74 20 73 65 74 49 6e 6e 65 72 48 54 4d 4c 20  rt setInnerHTML 
0050: 66 72 6f 6d 20 27 2e 2f 2e 2e 2f 63 6f 6d 6d 6f  from './../commo
0060: 6e 2f 75 74 69 6c 2f 64 6f 6d 2f 73 65 74 2d 69  n/util/dom/set-i
0070: 6e 6e 65 72 2d 48 54 4d 4c 27 0a 69 6d 70 6f 72  nner-HTML'.impor
0080: 74 20 24 20 66 72 6f 6d 20 27 2e 2f 2e 2e 2f 63  t $ from './../c
0090: 6f 6d 6d 6f 6e 2f 75 74 69 6c 2f 64 6f 6d 2f 24  ommon/util/dom/$
00a0: 27 0a 0a 69 6d 70 6f 72 74 20 7b 0a 20 20 49 45  '..import {.  IE
00b0: 5f 56 45 52 53 49 4f 4e 2c 0a 20 20 52 45 5f 53  _VERSION,.  RE_S
00c0: 50 45 43 49 41 4c 5f 54 41 47 53 2c 0a 20 20 52  PECIAL_TAGS,.  R
00d0: 45 5f 53 50 45 43 49 41 4c 5f 54 41 47 53 5f 4e  E_SPECIAL_TAGS_N
00e0: 4f 5f 4f 50 54 49 4f 4e 0a 7d 20 66 72 6f 6d 20  O_OPTION.} from 
00f0: 27 2e 2f 2e 2e 2f 63 6f 6d 6d 6f 6e 2f 67 6c 6f  './../common/glo
0100: 62 61 6c 2d 76 61 72 69 61 62 6c 65 73 27 0a 0a  bal-variables'..
0110: 2f 2a 0a 20 20 49 6e 63 6c 75 64 65 73 20 68 61  /*.  Includes ha
0120: 63 6b 73 20 6e 65 65 64 65 64 20 66 6f 72 20 74  cks needed for t
0130: 68 65 20 49 6e 74 65 72 6e 65 74 20 45 78 70 6c  he Internet Expl
0140: 6f 72 65 72 20 76 65 72 73 69 6f 6e 20 39 20 61  orer version 9 a
0150: 6e 64 20 62 65 6c 6f 77 0a 20 20 53 65 65 3a 20  nd below.  See: 
0160: 68 74 74 70 3a 2f 2f 6b 61 6e 67 61 78 2e 67 69  http://kangax.gi
0170: 74 68 75 62 2e 69 6f 2f 63 6f 6d 70 61 74 2d 74  thub.io/compat-t
0180: 61 62 6c 65 2f 65 73 35 2f 23 69 65 38 0a 20 20  able/es5/#ie8.  
0190: 20 20 20 20 20 68 74 74 70 3a 2f 2f 63 6f 64 65       http://code
01a0: 70 6c 61 6e 65 74 2e 69 6f 2f 64 72 6f 70 70 69  planet.io/droppi
01b0: 6e 67 2d 69 65 38 2f 0a 2a 2f 0a 0a 63 6f 6e 73  ng-ie8/.*/..cons
01c0: 74 0a 20 20 72 65 48 61 73 59 69 65 6c 64 20 20  t.  reHasYield  
01d0: 3d 20 2f 3c 79 69 65 6c 64 5c 62 2f 69 2c 0a 20  = /<yield\b/i,. 
01e0: 20 72 65 59 69 65 6c 64 41 6c 6c 20 20 3d 20 2f   reYieldAll  = /
01f0: 3c 79 69 65 6c 64 5c 73 2a 28 3f 3a 5c 2f 3e 7c  <yield\s*(?:\/>|
0200: 3e 28 5b 5c 53 5c 73 5d 2a 3f 29 3c 5c 2f 79 69  >([\S\s]*?)<\/yi
0210: 65 6c 64 5c 73 2a 3e 7c 3e 29 2f 69 67 2c 0a 20  eld\s*>|>)/ig,. 
0220: 20 72 65 59 69 65 6c 64 53 72 63 20 20 3d 20 2f   reYieldSrc  = /
0230: 3c 79 69 65 6c 64 5c 73 2b 74 6f 3d 5b 27 22 5d  <yield\s+to=['"]
0240: 28 5b 5e 27 22 3e 5d 2a 29 5b 27 22 5d 5c 73 2a  ([^'">]*)['"]\s*
0250: 3e 28 5b 5c 53 5c 73 5d 2a 3f 29 3c 5c 2f 79 69  >([\S\s]*?)<\/yi
0260: 65 6c 64 5c 73 2a 3e 2f 69 67 2c 0a 20 20 72 65  eld\s*>/ig,.  re
0270: 59 69 65 6c 64 44 65 73 74 20 3d 20 2f 3c 79 69  YieldDest = /<yi
0280: 65 6c 64 5c 73 2b 66 72 6f 6d 3d 5b 27 22 5d 3f  eld\s+from=['"]?
0290: 28 5b 2d 5c 77 5d 2b 29 5b 27 22 5d 3f 5c 73 2a  ([-\w]+)['"]?\s*
02a0: 28 3f 3a 5c 2f 3e 7c 3e 28 5b 5c 53 5c 73 5d 2a  (?:\/>|>([\S\s]*
02b0: 3f 29 3c 5c 2f 79 69 65 6c 64 5c 73 2a 3e 29 2f  ?)<\/yield\s*>)/
02c0: 69 67 2c 0a 20 20 72 6f 6f 74 45 6c 73 20 3d 20  ig,.  rootEls = 
02d0: 7b 20 74 72 3a 20 27 74 62 6f 64 79 27 2c 20 74  { tr: 'tbody', t
02e0: 68 3a 20 27 74 72 27 2c 20 74 64 3a 20 27 74 72  h: 'tr', td: 'tr
02f0: 27 2c 20 63 6f 6c 3a 20 27 63 6f 6c 67 72 6f 75  ', col: 'colgrou
0300: 70 27 20 7d 2c 0a 20 20 74 62 6c 54 61 67 73 20  p' },.  tblTags 
0310: 3d 20 49 45 5f 56 45 52 53 49 4f 4e 20 26 26 20  = IE_VERSION && 
0320: 49 45 5f 56 45 52 53 49 4f 4e 20 3c 20 31 30 20  IE_VERSION < 10 
0330: 3f 20 52 45 5f 53 50 45 43 49 41 4c 5f 54 41 47  ? RE_SPECIAL_TAG
0340: 53 20 3a 20 52 45 5f 53 50 45 43 49 41 4c 5f 54  S : RE_SPECIAL_T
0350: 41 47 53 5f 4e 4f 5f 4f 50 54 49 4f 4e 2c 0a 20  AGS_NO_OPTION,. 
0360: 20 47 45 4e 45 52 49 43 20 3d 20 27 64 69 76 27   GENERIC = 'div'
0370: 2c 0a 20 20 53 56 47 20 3d 20 27 73 76 67 27 0a  ,.  SVG = 'svg'.
0380: 0a 0a 2f 2a 0a 20 20 43 72 65 61 74 65 73 20 74  ../*.  Creates t
0390: 68 65 20 72 6f 6f 74 20 65 6c 65 6d 65 6e 74 20  he root element 
03a0: 66 6f 72 20 74 61 62 6c 65 20 6f 72 20 73 65 6c  for table or sel
03b0: 65 63 74 20 63 68 69 6c 64 20 65 6c 65 6d 65 6e  ect child elemen
03c0: 74 73 3a 0a 20 20 74 72 2f 74 68 2f 74 64 2f 74  ts:.  tr/th/td/t
03d0: 68 65 61 64 2f 74 66 6f 6f 74 2f 74 62 6f 64 79  head/tfoot/tbody
03e0: 2f 63 61 70 74 69 6f 6e 2f 63 6f 6c 2f 63 6f 6c  /caption/col/col
03f0: 67 72 6f 75 70 2f 6f 70 74 69 6f 6e 2f 6f 70 74  group/option/opt
0400: 67 72 6f 75 70 0a 2a 2f 0a 66 75 6e 63 74 69 6f  group.*/.functio
0410: 6e 20 73 70 65 63 69 61 6c 54 61 67 73 28 65 6c  n specialTags(el
0420: 2c 20 74 6d 70 6c 2c 20 74 61 67 4e 61 6d 65 29  , tmpl, tagName)
0430: 20 7b 0a 0a 20 20 6c 65 74 0a 20 20 20 20 73 65   {..  let.    se
0440: 6c 65 63 74 20 3d 20 74 61 67 4e 61 6d 65 5b 30  lect = tagName[0
0450: 5d 20 3d 3d 3d 20 27 6f 27 2c 0a 20 20 20 20 70  ] === 'o',.    p
0460: 61 72 65 6e 74 20 3d 20 73 65 6c 65 63 74 20 3f  arent = select ?
0470: 20 27 73 65 6c 65 63 74 3e 27 20 3a 20 27 74 61   'select>' : 'ta
0480: 62 6c 65 3e 27 0a 0a 20 20 2f 2f 20 74 72 69 6d  ble>'..  // trim
0490: 28 29 20 69 73 20 69 6d 70 6f 72 74 61 6e 74 20  () is important 
04a0: 68 65 72 65 2c 20 74 68 69 73 20 65 6e 73 75 72  here, this ensur
04b0: 65 73 20 77 65 20 64 6f 6e 27 74 20 68 61 76 65  es we don't have
04c0: 20 61 72 74 69 66 61 63 74 73 2c 0a 20 20 2f 2f   artifacts,.  //
04d0: 20 73 6f 20 77 65 20 63 61 6e 20 63 68 65 63 6b   so we can check
04e0: 20 69 66 20 77 65 20 68 61 76 65 20 6f 6e 6c 79   if we have only
04f0: 20 6f 6e 65 20 65 6c 65 6d 65 6e 74 20 69 6e 73   one element ins
0500: 69 64 65 20 74 68 65 20 70 61 72 65 6e 74 0a 20  ide the parent. 
0510: 20 65 6c 2e 69 6e 6e 65 72 48 54 4d 4c 20 3d 20   el.innerHTML = 
0520: 27 3c 27 20 2b 20 70 61 72 65 6e 74 20 2b 20 74  '<' + parent + t
0530: 6d 70 6c 2e 74 72 69 6d 28 29 20 2b 20 27 3c 2f  mpl.trim() + '</
0540: 27 20 2b 20 70 61 72 65 6e 74 0a 20 20 70 61 72  ' + parent.  par
0550: 65 6e 74 20 3d 20 65 6c 2e 66 69 72 73 74 43 68  ent = el.firstCh
0560: 69 6c 64 0a 0a 20 20 2f 2f 20 72 65 74 75 72 6e  ild..  // return
0570: 73 20 74 68 65 20 69 6d 6d 65 64 69 61 74 65 20  s the immediate 
0580: 70 61 72 65 6e 74 20 69 66 20 74 72 2f 74 68 2f  parent if tr/th/
0590: 74 64 2f 63 6f 6c 20 69 73 20 74 68 65 20 6f 6e  td/col is the on
05a0: 6c 79 20 65 6c 65 6d 65 6e 74 2c 20 69 66 20 6e  ly element, if n
05b0: 6f 74 0a 20 20 2f 2f 20 72 65 74 75 72 6e 73 20  ot.  // returns 
05c0: 74 68 65 20 77 68 6f 6c 65 20 74 72 65 65 2c 20  the whole tree, 
05d0: 61 73 20 74 68 69 73 20 63 61 6e 20 69 6e 63 6c  as this can incl
05e0: 75 64 65 20 61 64 64 69 74 69 6f 6e 61 6c 20 65  ude additional e
05f0: 6c 65 6d 65 6e 74 73 0a 20 20 2f 2a 20 69 73 74  lements.  /* ist
0600: 61 6e 62 75 6c 20 69 67 6e 6f 72 65 20 6e 65 78  anbul ignore nex
0610: 74 20 2a 2f 0a 20 20 69 66 20 28 73 65 6c 65 63  t */.  if (selec
0620: 74 29 20 7b 0a 20 20 20 20 70 61 72 65 6e 74 2e  t) {.    parent.
0630: 73 65 6c 65 63 74 65 64 49 6e 64 65 78 20 3d 20  selectedIndex = 
0640: 2d 31 20 20 2f 2f 20 66 6f 72 20 49 45 39 2c 20  -1  // for IE9, 
0650: 63 6f 6d 70 61 74 69 62 6c 65 20 77 2f 63 75 72  compatible w/cur
0660: 72 65 6e 74 20 72 69 6f 74 20 62 65 68 61 76 69  rent riot behavi
0670: 6f 72 0a 20 20 7d 20 65 6c 73 65 20 7b 0a 20 20  or.  } else {.  
0680: 20 20 2f 2f 20 61 76 6f 69 64 73 20 69 6e 73 65    // avoids inse
0690: 72 74 69 6f 6e 20 6f 66 20 63 6f 69 6e 74 61 69  rtion of cointai
06a0: 6e 65 72 20 69 6e 73 69 64 65 20 63 6f 6e 74 61  ner inside conta
06b0: 69 6e 65 72 20 28 65 78 3a 20 74 62 6f 64 79 20  iner (ex: tbody 
06c0: 69 6e 73 69 64 65 20 74 62 6f 64 79 29 0a 20 20  inside tbody).  
06d0: 20 20 63 6f 6e 73 74 20 74 6e 61 6d 65 20 3d 20    const tname = 
06e0: 72 6f 6f 74 45 6c 73 5b 74 61 67 4e 61 6d 65 5d  rootEls[tagName]
06f0: 0a 20 20 20 20 69 66 20 28 74 6e 61 6d 65 20 26  .    if (tname &
0700: 26 20 70 61 72 65 6e 74 2e 63 68 69 6c 64 45 6c  & parent.childEl
0710: 65 6d 65 6e 74 43 6f 75 6e 74 20 3d 3d 3d 20 31  ementCount === 1
0720: 29 20 70 61 72 65 6e 74 20 3d 20 24 28 74 6e 61  ) parent = $(tna
0730: 6d 65 2c 20 70 61 72 65 6e 74 29 0a 20 20 7d 0a  me, parent).  }.
0740: 20 20 72 65 74 75 72 6e 20 70 61 72 65 6e 74 0a    return parent.
0750: 7d 0a 0a 2f 2a 0a 20 20 52 65 70 6c 61 63 65 20  }../*.  Replace 
0760: 74 68 65 20 79 69 65 6c 64 20 74 61 67 20 66 72  the yield tag fr
0770: 6f 6d 20 61 6e 79 20 74 61 67 20 74 65 6d 70 6c  om any tag templ
0780: 61 74 65 20 77 69 74 68 20 74 68 65 20 69 6e 6e  ate with the inn
0790: 65 72 48 54 4d 4c 20 6f 66 20 74 68 65 0a 20 20  erHTML of the.  
07a0: 6f 72 69 67 69 6e 61 6c 20 74 61 67 20 69 6e 20  original tag in 
07b0: 74 68 65 20 70 61 67 65 0a 2a 2f 0a 66 75 6e 63  the page.*/.func
07c0: 74 69 6f 6e 20 72 65 70 6c 61 63 65 59 69 65 6c  tion replaceYiel
07d0: 64 28 74 6d 70 6c 2c 20 68 74 6d 6c 29 20 7b 0a  d(tmpl, html) {.
07e0: 20 20 2f 2f 20 64 6f 20 6e 6f 74 68 69 6e 67 20    // do nothing 
07f0: 69 66 20 6e 6f 20 79 69 65 6c 64 0a 20 20 69 66  if no yield.  if
0800: 20 28 21 72 65 48 61 73 59 69 65 6c 64 2e 74 65   (!reHasYield.te
0810: 73 74 28 74 6d 70 6c 29 29 20 72 65 74 75 72 6e  st(tmpl)) return
0820: 20 74 6d 70 6c 0a 0a 20 20 2f 2f 20 62 65 20 63   tmpl..  // be c
0830: 61 72 65 66 75 6c 20 77 69 74 68 20 23 31 33 34  areful with #134
0840: 33 20 2d 20 73 74 72 69 6e 67 20 6f 6e 20 74 68  3 - string on th
0850: 65 20 73 6f 75 72 63 65 20 68 61 76 69 6e 67 20  e source having 
0860: 60 24 31 60 0a 20 20 63 6f 6e 73 74 20 73 72 63  `$1`.  const src
0870: 20 3d 20 7b 7d 0a 0a 20 20 68 74 6d 6c 20 3d 20   = {}..  html = 
0880: 68 74 6d 6c 20 26 26 20 68 74 6d 6c 2e 72 65 70  html && html.rep
0890: 6c 61 63 65 28 72 65 59 69 65 6c 64 53 72 63 2c  lace(reYieldSrc,
08a0: 20 66 75 6e 63 74 69 6f 6e 20 28 5f 2c 20 72 65   function (_, re
08b0: 66 2c 20 74 65 78 74 29 20 7b 0a 20 20 20 20 73  f, text) {.    s
08c0: 72 63 5b 72 65 66 5d 20 3d 20 73 72 63 5b 72 65  rc[ref] = src[re
08d0: 66 5d 20 7c 7c 20 74 65 78 74 20 20 20 2f 2f 20  f] || text   // 
08e0: 70 72 65 73 65 72 76 65 20 66 69 72 73 74 20 64  preserve first d
08f0: 65 66 69 6e 69 74 69 6f 6e 0a 20 20 20 20 72 65  efinition.    re
0900: 74 75 72 6e 20 27 27 0a 20 20 7d 29 2e 74 72 69  turn ''.  }).tri
0910: 6d 28 29 0a 0a 20 20 72 65 74 75 72 6e 20 74 6d  m()..  return tm
0920: 70 6c 0a 20 20 20 20 2e 72 65 70 6c 61 63 65 28  pl.    .replace(
0930: 72 65 59 69 65 6c 64 44 65 73 74 2c 20 66 75 6e  reYieldDest, fun
0940: 63 74 69 6f 6e 20 28 5f 2c 20 72 65 66 2c 20 64  ction (_, ref, d
0950: 65 66 29 20 7b 20 20 2f 2f 20 79 69 65 6c 64 20  ef) {  // yield 
0960: 77 69 74 68 20 66 72 6f 6d 20 2d 20 74 6f 20 61  with from - to a
0970: 74 74 72 73 0a 20 20 20 20 20 20 72 65 74 75 72  ttrs.      retur
0980: 6e 20 73 72 63 5b 72 65 66 5d 20 7c 7c 20 64 65  n src[ref] || de
0990: 66 20 7c 7c 20 27 27 0a 20 20 20 20 7d 29 0a 20  f || ''.    }). 
09a0: 20 20 20 2e 72 65 70 6c 61 63 65 28 72 65 59 69     .replace(reYi
09b0: 65 6c 64 41 6c 6c 2c 20 66 75 6e 63 74 69 6f 6e  eldAll, function
09c0: 20 28 5f 2c 20 64 65 66 29 20 7b 20 20 20 20 20   (_, def) {     
09d0: 20 20 20 2f 2f 20 79 69 65 6c 64 20 77 69 74 68     // yield with
09e0: 6f 75 74 20 61 6e 79 20 22 66 72 6f 6d 22 0a 20  out any "from". 
09f0: 20 20 20 20 20 72 65 74 75 72 6e 20 68 74 6d 6c       return html
0a00: 20 7c 7c 20 64 65 66 20 7c 7c 20 27 27 0a 20 20   || def || ''.  
0a10: 20 20 7d 29 0a 7d 0a 0a 2f 2a 2a 0a 20 2a 20 43    }).}../**. * C
0a20: 72 65 61 74 65 73 20 61 20 44 4f 4d 20 65 6c 65  reates a DOM ele
0a30: 6d 65 6e 74 20 74 6f 20 77 72 61 70 20 74 68 65  ment to wrap the
0a40: 20 67 69 76 65 6e 20 63 6f 6e 74 65 6e 74 2e 20   given content. 
0a50: 4e 6f 72 6d 61 6c 6c 79 20 61 6e 20 60 44 49 56  Normally an `DIV
0a60: 60 2c 20 62 75 74 20 63 61 6e 20 62 65 0a 20 2a  `, but can be. *
0a70: 20 61 6c 73 6f 20 61 20 60 54 41 42 4c 45 60 2c   also a `TABLE`,
0a80: 20 60 53 45 4c 45 43 54 60 2c 20 60 54 42 4f 44   `SELECT`, `TBOD
0a90: 59 60 2c 20 60 54 52 60 2c 20 6f 72 20 60 43 4f  Y`, `TR`, or `CO
0aa0: 4c 47 52 4f 55 50 60 20 65 6c 65 6d 65 6e 74 2e  LGROUP` element.
0ab0: 0a 20 2a 0a 20 2a 20 40 70 61 72 61 6d 20 20 20  . *. * @param   
0ac0: 7b 20 53 74 72 69 6e 67 20 7d 20 74 6d 70 6c 20  { String } tmpl 
0ad0: 20 2d 20 54 68 65 20 74 65 6d 70 6c 61 74 65 20   - The template 
0ae0: 63 6f 6d 69 6e 67 20 66 72 6f 6d 20 74 68 65 20  coming from the 
0af0: 63 75 73 74 6f 6d 20 74 61 67 20 64 65 66 69 6e  custom tag defin
0b00: 69 74 69 6f 6e 0a 20 2a 20 40 70 61 72 61 6d 20  ition. * @param 
0b10: 20 20 7b 20 53 74 72 69 6e 67 20 7d 20 68 74 6d    { String } htm
0b20: 6c 20 2d 20 48 54 4d 4c 20 63 6f 6e 74 65 6e 74  l - HTML content
0b30: 20 74 68 61 74 20 63 6f 6d 65 73 20 66 72 6f 6d   that comes from
0b40: 20 74 68 65 20 44 4f 4d 20 65 6c 65 6d 65 6e 74   the DOM element
0b50: 20 77 68 65 72 65 20 79 6f 75 0a 20 2a 20 20 20   where you. *   
0b60: 20 20 20 20 20 20 20 20 77 69 6c 6c 20 6d 6f 75          will mou
0b70: 6e 74 20 74 68 65 20 74 61 67 2c 20 6d 6f 73 74  nt the tag, most
0b80: 6c 79 20 74 68 65 20 6f 72 69 67 69 6e 61 6c 20  ly the original 
0b90: 74 61 67 20 69 6e 20 74 68 65 20 70 61 67 65 0a  tag in the page.
0ba0: 20 2a 20 40 70 61 72 61 6d 20 20 20 7b 20 42 6f   * @param   { Bo
0bb0: 6f 6c 65 61 6e 20 7d 20 69 73 53 76 67 20 2d 20  olean } isSvg - 
0bc0: 74 72 75 65 20 69 66 20 74 68 65 20 72 6f 6f 74  true if the root
0bd0: 20 6e 6f 64 65 20 69 73 20 61 6e 20 73 76 67 0a   node is an svg.
0be0: 20 2a 20 40 72 65 74 75 72 6e 73 20 7b 20 48 54   * @returns { HT
0bf0: 4d 4c 45 6c 65 6d 65 6e 74 20 7d 20 44 4f 4d 20  MLElement } DOM 
0c00: 65 6c 65 6d 65 6e 74 20 77 69 74 68 20 5f 74 6d  element with _tm
0c10: 70 6c 5f 20 6d 65 72 67 65 64 20 74 68 72 6f 75  pl_ merged throu
0c20: 67 68 20 60 59 49 45 4c 44 60 20 77 69 74 68 20  gh `YIELD` with 
0c30: 74 68 65 20 5f 68 74 6d 6c 5f 2e 0a 20 2a 2f 0a  the _html_.. */.
0c40: 65 78 70 6f 72 74 20 64 65 66 61 75 6c 74 20 66  export default f
0c50: 75 6e 63 74 69 6f 6e 20 6d 6b 64 6f 6d 28 74 6d  unction mkdom(tm
0c60: 70 6c 2c 20 68 74 6d 6c 2c 20 69 73 53 76 67 29  pl, html, isSvg)
0c70: 20 7b 0a 20 20 63 6f 6e 73 74 20 6d 61 74 63 68   {.  const match
0c80: 20 20 20 3d 20 74 6d 70 6c 20 26 26 20 74 6d 70     = tmpl && tmp
0c90: 6c 2e 6d 61 74 63 68 28 2f 5e 5c 73 2a 3c 28 5b  l.match(/^\s*<([
0ca0: 2d 5c 77 5d 2b 29 2f 29 0a 20 20 63 6f 6e 73 74  -\w]+)/).  const
0cb0: 20 20 74 61 67 4e 61 6d 65 20 3d 20 6d 61 74 63    tagName = matc
0cc0: 68 20 26 26 20 6d 61 74 63 68 5b 31 5d 2e 74 6f  h && match[1].to
0cd0: 4c 6f 77 65 72 43 61 73 65 28 29 0a 20 20 6c 65  LowerCase().  le
0ce0: 74 20 65 6c 20 3d 20 6d 61 6b 65 45 6c 65 6d 65  t el = makeEleme
0cf0: 6e 74 28 69 73 53 76 67 20 3f 20 53 56 47 20 3a  nt(isSvg ? SVG :
0d00: 20 47 45 4e 45 52 49 43 29 0a 0a 20 20 2f 2f 20   GENERIC)..  // 
0d10: 72 65 70 6c 61 63 65 20 61 6c 6c 20 74 68 65 20  replace all the 
0d20: 79 69 65 6c 64 20 74 61 67 73 20 77 69 74 68 20  yield tags with 
0d30: 74 68 65 20 74 61 67 20 69 6e 6e 65 72 20 68 74  the tag inner ht
0d40: 6d 6c 0a 20 20 74 6d 70 6c 20 3d 20 72 65 70 6c  ml.  tmpl = repl
0d50: 61 63 65 59 69 65 6c 64 28 74 6d 70 6c 2c 20 68  aceYield(tmpl, h
0d60: 74 6d 6c 29 0a 0a 20 20 2f 2a 20 69 73 74 61 6e  tml)..  /* istan
0d70: 62 75 6c 20 69 67 6e 6f 72 65 20 6e 65 78 74 20  bul ignore next 
0d80: 2a 2f 0a 20 20 69 66 20 28 74 62 6c 54 61 67 73  */.  if (tblTags
0d90: 2e 74 65 73 74 28 74 61 67 4e 61 6d 65 29 29 0a  .test(tagName)).
0da0: 20 20 20 20 65 6c 20 3d 20 73 70 65 63 69 61 6c      el = special
0db0: 54 61 67 73 28 65 6c 2c 20 74 6d 70 6c 2c 20 74  Tags(el, tmpl, t
0dc0: 61 67 4e 61 6d 65 29 0a 20 20 65 6c 73 65 0a 20  agName).  else. 
0dd0: 20 20 20 73 65 74 49 6e 6e 65 72 48 54 4d 4c 28     setInnerHTML(
0de0: 65 6c 2c 20 74 6d 70 6c 2c 20 69 73 53 76 67 29  el, tmpl, isSvg)
0df0: 0a 0a 20 20 72 65 74 75 72 6e 20 65 6c 0a 7d 0a  ..  return el.}.