⌈⌋ ⎇ branch:  Bitrhythm


Hex Artifact Content

Artifact 1c97ba2ac55207d366f5e6ea92481e99e27d6ea3675e2beb030bb53c361cd50f:


0000: 69 6d 70 6f 72 74 20 7b 20 74 6d 70 6c 20 7d 20  import { tmpl } 
0010: 66 72 6f 6d 20 27 72 69 6f 74 2d 74 6d 70 6c 27  from 'riot-tmpl'
0020: 0a 69 6d 70 6f 72 74 20 65 61 63 68 20 66 72 6f  .import each fro
0030: 6d 20 27 2e 2f 2e 2e 2f 63 6f 6d 6d 6f 6e 2f 75  m './../common/u
0040: 74 69 6c 2f 6d 69 73 63 2f 65 61 63 68 27 0a 69  til/misc/each'.i
0050: 6d 70 6f 72 74 20 63 6f 6e 74 61 69 6e 73 20 66  mport contains f
0060: 72 6f 6d 20 27 2e 2f 2e 2e 2f 63 6f 6d 6d 6f 6e  rom './../common
0070: 2f 75 74 69 6c 2f 6d 69 73 63 2f 63 6f 6e 74 61  /util/misc/conta
0080: 69 6e 73 27 0a 69 6d 70 6f 72 74 20 72 69 6f 74  ins'.import riot
0090: 53 65 74 74 69 6e 67 73 20 66 72 6f 6d 20 27 2e  Settings from '.
00a0: 2e 2f 2e 2e 2f 73 65 74 74 69 6e 67 73 27 0a 0a  ./../settings'..
00b0: 69 6d 70 6f 72 74 20 69 73 42 6c 61 6e 6b 20 66  import isBlank f
00c0: 72 6f 6d 20 27 2e 2f 2e 2e 2f 63 6f 6d 6d 6f 6e  rom './../common
00d0: 2f 75 74 69 6c 2f 63 68 65 63 6b 73 2f 69 73 2d  /util/checks/is-
00e0: 62 6c 61 6e 6b 27 0a 69 6d 70 6f 72 74 20 69 73  blank'.import is
00f0: 4f 62 6a 65 63 74 20 66 72 6f 6d 20 27 2e 2f 2e  Object from './.
0100: 2e 2f 63 6f 6d 6d 6f 6e 2f 75 74 69 6c 2f 63 68  ./common/util/ch
0110: 65 63 6b 73 2f 69 73 2d 6f 62 6a 65 63 74 27 0a  ecks/is-object'.
0120: 69 6d 70 6f 72 74 20 69 73 53 74 72 69 6e 67 20  import isString 
0130: 66 72 6f 6d 20 27 2e 2f 2e 2e 2f 63 6f 6d 6d 6f  from './../commo
0140: 6e 2f 75 74 69 6c 2f 63 68 65 63 6b 73 2f 69 73  n/util/checks/is
0150: 2d 73 74 72 69 6e 67 27 0a 69 6d 70 6f 72 74 20  -string'.import 
0160: 69 73 46 75 6e 63 74 69 6f 6e 20 66 72 6f 6d 20  isFunction from 
0170: 27 2e 2f 2e 2e 2f 63 6f 6d 6d 6f 6e 2f 75 74 69  './../common/uti
0180: 6c 2f 63 68 65 63 6b 73 2f 69 73 2d 66 75 6e 63  l/checks/is-func
0190: 74 69 6f 6e 27 0a 0a 69 6d 70 6f 72 74 20 72 65  tion'..import re
01a0: 6d 6f 76 65 41 74 74 72 69 62 75 74 65 20 66 72  moveAttribute fr
01b0: 6f 6d 20 27 2e 2f 2e 2e 2f 63 6f 6d 6d 6f 6e 2f  om './../common/
01c0: 75 74 69 6c 2f 64 6f 6d 2f 72 65 6d 6f 76 65 2d  util/dom/remove-
01d0: 61 74 74 72 69 62 75 74 65 27 0a 69 6d 70 6f 72  attribute'.impor
01e0: 74 20 67 65 74 41 74 74 72 69 62 75 74 65 20 66  t getAttribute f
01f0: 72 6f 6d 20 27 2e 2f 2e 2e 2f 63 6f 6d 6d 6f 6e  rom './../common
0200: 2f 75 74 69 6c 2f 64 6f 6d 2f 67 65 74 2d 61 74  /util/dom/get-at
0210: 74 72 69 62 75 74 65 27 0a 69 6d 70 6f 72 74 20  tribute'.import 
0220: 73 65 74 41 74 74 72 69 62 75 74 65 20 66 72 6f  setAttribute fro
0230: 6d 20 27 2e 2f 2e 2e 2f 63 6f 6d 6d 6f 6e 2f 75  m './../common/u
0240: 74 69 6c 2f 64 6f 6d 2f 73 65 74 2d 61 74 74 72  til/dom/set-attr
0250: 69 62 75 74 65 27 0a 69 6d 70 6f 72 74 20 63 72  ibute'.import cr
0260: 65 61 74 65 50 6c 61 63 65 68 6f 6c 64 65 72 20  eatePlaceholder 
0270: 66 72 6f 6d 20 27 2e 2f 2e 2e 2f 63 6f 6d 6d 6f  from './../commo
0280: 6e 2f 75 74 69 6c 2f 64 6f 6d 2f 63 72 65 61 74  n/util/dom/creat
0290: 65 2d 70 6c 61 63 65 68 6f 6c 64 65 72 27 0a 69  e-placeholder'.i
02a0: 6d 70 6f 72 74 20 74 6f 67 67 6c 65 56 69 73 69  mport toggleVisi
02b0: 62 69 6c 69 74 79 20 66 72 6f 6d 20 27 2e 2f 2e  bility from './.
02c0: 2e 2f 63 6f 6d 6d 6f 6e 2f 75 74 69 6c 2f 64 6f  ./common/util/do
02d0: 6d 2f 74 6f 67 67 6c 65 2d 76 69 73 69 62 69 6c  m/toggle-visibil
02e0: 69 74 79 27 0a 69 6d 70 6f 72 74 20 73 74 79 6c  ity'.import styl
02f0: 65 4f 62 6a 65 63 74 54 6f 53 74 72 69 6e 67 20  eObjectToString 
0300: 66 72 6f 6d 20 27 2e 2f 2e 2e 2f 63 6f 6d 6d 6f  from './../commo
0310: 6e 2f 75 74 69 6c 2f 64 6f 6d 2f 73 74 79 6c 65  n/util/dom/style
0320: 2d 6f 62 6a 65 63 74 2d 74 6f 2d 73 74 72 69 6e  -object-to-strin
0330: 67 27 0a 69 6d 70 6f 72 74 20 69 73 45 76 65 6e  g'.import isEven
0340: 74 41 74 74 72 69 62 75 74 65 20 66 72 6f 6d 20  tAttribute from 
0350: 27 2e 2f 2e 2e 2f 63 6f 6d 6d 6f 6e 2f 75 74 69  './../common/uti
0360: 6c 2f 6d 69 73 63 2f 69 73 2d 65 76 65 6e 74 2d  l/misc/is-event-
0370: 61 74 74 72 69 62 75 74 65 27 0a 0a 69 6d 70 6f  attribute'..impo
0380: 72 74 20 73 65 74 45 76 65 6e 74 48 61 6e 64 6c  rt setEventHandl
0390: 65 72 20 66 72 6f 6d 20 27 2e 2f 73 65 74 45 76  er from './setEv
03a0: 65 6e 74 48 61 6e 64 6c 65 72 27 0a 0a 69 6d 70  entHandler'..imp
03b0: 6f 72 74 20 69 6e 69 74 43 68 69 6c 64 20 66 72  ort initChild fr
03c0: 6f 6d 20 27 2e 2f 2e 2e 2f 63 6f 6d 6d 6f 6e 2f  om './../common/
03d0: 75 74 69 6c 2f 74 61 67 73 2f 69 6e 69 74 2d 63  util/tags/init-c
03e0: 68 69 6c 64 27 0a 69 6d 70 6f 72 74 20 61 72 72  hild'.import arr
03f0: 61 79 69 73 68 52 65 6d 6f 76 65 20 66 72 6f 6d  ayishRemove from
0400: 20 27 2e 2f 2e 2e 2f 63 6f 6d 6d 6f 6e 2f 75 74   './../common/ut
0410: 69 6c 2f 74 61 67 73 2f 61 72 72 61 79 69 73 68  il/tags/arrayish
0420: 2d 72 65 6d 6f 76 65 27 0a 69 6d 70 6f 72 74 20  -remove'.import 
0430: 69 6e 68 65 72 69 74 50 61 72 65 6e 74 50 72 6f  inheritParentPro
0440: 70 73 20 66 72 6f 6d 20 27 2e 2f 2e 2e 2f 63 6f  ps from './../co
0450: 6d 6d 6f 6e 2f 75 74 69 6c 2f 74 61 67 73 2f 69  mmon/util/tags/i
0460: 6e 68 65 72 69 74 2d 70 61 72 65 6e 74 2d 70 72  nherit-parent-pr
0470: 6f 70 65 72 74 69 65 73 27 0a 69 6d 70 6f 72 74  operties'.import
0480: 20 72 65 70 6c 61 63 65 56 69 72 74 75 61 6c 20   replaceVirtual 
0490: 66 72 6f 6d 20 27 2e 2f 2e 2e 2f 63 6f 6d 6d 6f  from './../commo
04a0: 6e 2f 75 74 69 6c 2f 74 61 67 73 2f 72 65 70 6c  n/util/tags/repl
04b0: 61 63 65 2d 76 69 72 74 75 61 6c 27 0a 0a 69 6d  ace-virtual'..im
04c0: 70 6f 72 74 20 7b 0a 20 20 5f 5f 54 41 47 5f 49  port {.  __TAG_I
04d0: 4d 50 4c 2c 0a 20 20 41 54 54 52 53 5f 50 52 45  MPL,.  ATTRS_PRE
04e0: 46 49 58 2c 0a 20 20 53 48 4f 57 5f 44 49 52 45  FIX,.  SHOW_DIRE
04f0: 43 54 49 56 45 2c 0a 20 20 48 49 44 45 5f 44 49  CTIVE,.  HIDE_DI
0500: 52 45 43 54 49 56 45 2c 0a 20 20 49 45 5f 56 45  RECTIVE,.  IE_VE
0510: 52 53 49 4f 4e 2c 0a 20 20 43 41 53 45 5f 53 45  RSION,.  CASE_SE
0520: 4e 53 49 54 49 56 45 5f 41 54 54 52 49 42 55 54  NSITIVE_ATTRIBUT
0530: 45 53 0a 7d 20 66 72 6f 6d 20 27 2e 2f 2e 2e 2f  ES.} from './../
0540: 63 6f 6d 6d 6f 6e 2f 67 6c 6f 62 61 6c 2d 76 61  common/global-va
0550: 72 69 61 62 6c 65 73 27 0a 0a 2f 2a 2a 0a 20 2a  riables'../**. *
0560: 20 55 70 64 61 74 65 20 64 79 6e 61 6d 69 63 61   Update dynamica
0570: 6c 6c 79 20 63 72 65 61 74 65 64 20 64 61 74 61  lly created data
0580: 2d 69 73 20 74 61 67 73 20 77 69 74 68 20 63 68  -is tags with ch
0590: 61 6e 67 69 6e 67 20 65 78 70 72 65 73 73 69 6f  anging expressio
05a0: 6e 73 0a 20 2a 20 40 70 61 72 61 6d 20 7b 20 4f  ns. * @param { O
05b0: 62 6a 65 63 74 20 7d 20 65 78 70 72 20 2d 20 65  bject } expr - e
05c0: 78 70 72 65 73 73 69 6f 6e 20 74 61 67 20 61 6e  xpression tag an
05d0: 64 20 65 78 70 72 65 73 73 69 6f 6e 20 69 6e 66  d expression inf
05e0: 6f 0a 20 2a 20 40 70 61 72 61 6d 20 7b 20 54 61  o. * @param { Ta
05f0: 67 20 7d 20 20 20 20 70 61 72 65 6e 74 20 2d 20  g }    parent - 
0600: 70 61 72 65 6e 74 20 66 6f 72 20 74 61 67 20 63  parent for tag c
0610: 72 65 61 74 69 6f 6e 0a 20 2a 20 40 70 61 72 61  reation. * @para
0620: 6d 20 7b 20 53 74 72 69 6e 67 20 7d 20 74 61 67  m { String } tag
0630: 4e 61 6d 65 20 2d 20 74 61 67 20 69 6d 70 6c 65  Name - tag imple
0640: 6d 65 6e 74 61 74 69 6f 6e 20 77 65 20 77 61 6e  mentation we wan
0650: 74 20 74 6f 20 75 73 65 0a 20 2a 2f 0a 65 78 70  t to use. */.exp
0660: 6f 72 74 20 66 75 6e 63 74 69 6f 6e 20 75 70 64  ort function upd
0670: 61 74 65 44 61 74 61 49 73 28 65 78 70 72 2c 20  ateDataIs(expr, 
0680: 70 61 72 65 6e 74 2c 20 74 61 67 4e 61 6d 65 29  parent, tagName)
0690: 20 7b 0a 20 20 6c 65 74 20 74 61 67 20 3d 20 65   {.  let tag = e
06a0: 78 70 72 2e 74 61 67 20 7c 7c 20 65 78 70 72 2e  xpr.tag || expr.
06b0: 64 6f 6d 2e 5f 74 61 67 0a 20 20 6c 65 74 20 72  dom._tag.  let r
06c0: 65 66 0a 0a 20 20 63 6f 6e 73 74 20 7b 20 68 65  ef..  const { he
06d0: 61 64 20 7d 20 3d 20 74 61 67 20 3f 20 74 61 67  ad } = tag ? tag
06e0: 2e 5f 5f 20 3a 20 7b 7d 0a 20 20 63 6f 6e 73 74  .__ : {}.  const
06f0: 20 69 73 56 69 72 74 75 61 6c 20 3d 20 65 78 70   isVirtual = exp
0700: 72 2e 64 6f 6d 2e 74 61 67 4e 61 6d 65 20 3d 3d  r.dom.tagName ==
0710: 3d 20 27 56 49 52 54 55 41 4c 27 0a 0a 20 20 69  = 'VIRTUAL'..  i
0720: 66 20 28 74 61 67 20 26 26 20 65 78 70 72 2e 74  f (tag && expr.t
0730: 61 67 4e 61 6d 65 20 3d 3d 3d 20 74 61 67 4e 61  agName === tagNa
0740: 6d 65 29 20 7b 0a 20 20 20 20 74 61 67 2e 75 70  me) {.    tag.up
0750: 64 61 74 65 28 29 0a 20 20 20 20 72 65 74 75 72  date().    retur
0760: 6e 0a 20 20 7d 0a 0a 20 20 2f 2f 20 73 79 6e 63  n.  }..  // sync
0770: 20 5f 70 61 72 65 6e 74 20 74 6f 20 61 63 63 6f   _parent to acco
0780: 6d 6d 6f 64 61 74 65 20 63 68 61 6e 67 69 6e 67  mmodate changing
0790: 20 74 61 67 6e 61 6d 65 73 0a 20 20 69 66 20 28   tagnames.  if (
07a0: 74 61 67 29 20 7b 0a 20 20 20 20 2f 2f 20 6e 65  tag) {.    // ne
07b0: 65 64 20 70 6c 61 63 65 68 6f 6c 64 65 72 20 62  ed placeholder b
07c0: 65 66 6f 72 65 20 75 6e 6d 6f 75 6e 74 0a 20 20  efore unmount.  
07d0: 20 20 69 66 28 69 73 56 69 72 74 75 61 6c 29 20    if(isVirtual) 
07e0: 7b 0a 20 20 20 20 20 20 72 65 66 20 3d 20 63 72  {.      ref = cr
07f0: 65 61 74 65 50 6c 61 63 65 68 6f 6c 64 65 72 28  eatePlaceholder(
0800: 29 0a 20 20 20 20 20 20 68 65 61 64 2e 70 61 72  ).      head.par
0810: 65 6e 74 4e 6f 64 65 2e 69 6e 73 65 72 74 42 65  entNode.insertBe
0820: 66 6f 72 65 28 72 65 66 2c 20 68 65 61 64 29 0a  fore(ref, head).
0830: 20 20 20 20 7d 0a 0a 20 20 20 20 74 61 67 2e 75      }..    tag.u
0840: 6e 6d 6f 75 6e 74 28 74 72 75 65 29 0a 20 20 7d  nmount(true).  }
0850: 0a 0a 20 20 2f 2f 20 75 6e 61 62 6c 65 20 74 6f  ..  // unable to
0860: 20 67 65 74 20 74 68 65 20 74 61 67 20 6e 61 6d   get the tag nam
0870: 65 0a 20 20 69 66 20 28 21 69 73 53 74 72 69 6e  e.  if (!isStrin
0880: 67 28 74 61 67 4e 61 6d 65 29 29 20 72 65 74 75  g(tagName)) retu
0890: 72 6e 0a 0a 20 20 65 78 70 72 2e 69 6d 70 6c 20  rn..  expr.impl 
08a0: 3d 20 5f 5f 54 41 47 5f 49 4d 50 4c 5b 74 61 67  = __TAG_IMPL[tag
08b0: 4e 61 6d 65 5d 0a 0a 20 20 2f 2f 20 75 6e 6b 6e  Name]..  // unkn
08c0: 6f 77 6e 20 69 6d 70 6c 65 6d 65 6e 74 61 74 69  own implementati
08d0: 6f 6e 0a 20 20 69 66 20 28 21 65 78 70 72 2e 69  on.  if (!expr.i
08e0: 6d 70 6c 29 20 72 65 74 75 72 6e 0a 0a 20 20 65  mpl) return..  e
08f0: 78 70 72 2e 74 61 67 20 3d 20 74 61 67 20 3d 20  xpr.tag = tag = 
0900: 69 6e 69 74 43 68 69 6c 64 28 0a 20 20 20 20 65  initChild(.    e
0910: 78 70 72 2e 69 6d 70 6c 2c 20 7b 0a 20 20 20 20  xpr.impl, {.    
0920: 20 20 72 6f 6f 74 3a 20 65 78 70 72 2e 64 6f 6d    root: expr.dom
0930: 2c 0a 20 20 20 20 20 20 70 61 72 65 6e 74 2c 0a  ,.      parent,.
0940: 20 20 20 20 20 20 74 61 67 4e 61 6d 65 0a 20 20        tagName.  
0950: 20 20 7d 2c 0a 20 20 20 20 65 78 70 72 2e 64 6f    },.    expr.do
0960: 6d 2e 69 6e 6e 65 72 48 54 4d 4c 2c 0a 20 20 20  m.innerHTML,.   
0970: 20 70 61 72 65 6e 74 0a 20 20 29 0a 0a 20 20 65   parent.  )..  e
0980: 61 63 68 28 65 78 70 72 2e 61 74 74 72 73 2c 20  ach(expr.attrs, 
0990: 61 20 3d 3e 20 73 65 74 41 74 74 72 69 62 75 74  a => setAttribut
09a0: 65 28 74 61 67 2e 72 6f 6f 74 2c 20 61 2e 6e 61  e(tag.root, a.na
09b0: 6d 65 2c 20 61 2e 76 61 6c 75 65 29 29 0a 20 20  me, a.value)).  
09c0: 65 78 70 72 2e 74 61 67 4e 61 6d 65 20 3d 20 74  expr.tagName = t
09d0: 61 67 4e 61 6d 65 0a 20 20 74 61 67 2e 6d 6f 75  agName.  tag.mou
09e0: 6e 74 28 29 0a 0a 20 20 2f 2f 20 72 6f 6f 74 20  nt()..  // root 
09f0: 65 78 69 73 74 20 66 69 72 73 74 20 74 69 6d 65  exist first time
0a00: 2c 20 61 66 74 65 72 20 75 73 65 20 70 6c 61 63  , after use plac
0a10: 65 68 6f 6c 64 65 72 0a 20 20 69 66 20 28 69 73  eholder.  if (is
0a20: 56 69 72 74 75 61 6c 29 20 72 65 70 6c 61 63 65  Virtual) replace
0a30: 56 69 72 74 75 61 6c 28 74 61 67 2c 20 72 65 66  Virtual(tag, ref
0a40: 20 7c 7c 20 74 61 67 2e 72 6f 6f 74 29 0a 0a 20   || tag.root).. 
0a50: 20 2f 2f 20 70 61 72 65 6e 74 20 69 73 20 74 68   // parent is th
0a60: 65 20 70 6c 61 63 65 68 6f 6c 64 65 72 20 74 61  e placeholder ta
0a70: 67 2c 20 6e 6f 74 20 74 68 65 20 64 79 6e 61 6d  g, not the dynam
0a80: 69 63 20 74 61 67 20 73 6f 20 63 6c 65 61 6e 20  ic tag so clean 
0a90: 75 70 0a 20 20 70 61 72 65 6e 74 2e 5f 5f 2e 6f  up.  parent.__.o
0aa0: 6e 55 6e 6d 6f 75 6e 74 20 3d 20 28 29 20 3d 3e  nUnmount = () =>
0ab0: 20 7b 0a 20 20 20 20 63 6f 6e 73 74 20 64 65 6c   {.    const del
0ac0: 4e 61 6d 65 20 3d 20 74 61 67 2e 6f 70 74 73 2e  Name = tag.opts.
0ad0: 64 61 74 61 49 73 0a 20 20 20 20 61 72 72 61 79  dataIs.    array
0ae0: 69 73 68 52 65 6d 6f 76 65 28 74 61 67 2e 70 61  ishRemove(tag.pa
0af0: 72 65 6e 74 2e 74 61 67 73 2c 20 64 65 6c 4e 61  rent.tags, delNa
0b00: 6d 65 2c 20 74 61 67 29 0a 20 20 20 20 61 72 72  me, tag).    arr
0b10: 61 79 69 73 68 52 65 6d 6f 76 65 28 74 61 67 2e  ayishRemove(tag.
0b20: 5f 5f 2e 70 61 72 65 6e 74 2e 74 61 67 73 2c 20  __.parent.tags, 
0b30: 64 65 6c 4e 61 6d 65 2c 20 74 61 67 29 0a 20 20  delName, tag).  
0b40: 20 20 74 61 67 2e 75 6e 6d 6f 75 6e 74 28 29 0a    tag.unmount().
0b50: 20 20 7d 0a 7d 0a 0a 2f 2a 2a 0a 20 2a 20 4e 6f    }.}../**. * No
0b60: 6d 61 6c 69 7a 65 20 61 6e 79 20 61 74 74 72 69  malize any attri
0b70: 62 75 74 65 20 72 65 6d 6f 76 69 6e 67 20 74 68  bute removing th
0b80: 65 20 22 72 69 6f 74 2d 22 20 70 72 65 66 69 78  e "riot-" prefix
0b90: 0a 20 2a 20 40 70 61 72 61 6d 20 20 20 7b 20 53  . * @param   { S
0ba0: 74 72 69 6e 67 20 7d 20 61 74 74 72 4e 61 6d 65  tring } attrName
0bb0: 20 2d 20 6f 72 69 67 69 6e 61 6c 20 61 74 74 72   - original attr
0bc0: 69 62 75 74 65 20 6e 61 6d 65 0a 20 2a 20 40 72  ibute name. * @r
0bd0: 65 74 75 72 6e 73 20 7b 20 53 74 72 69 6e 67 20  eturns { String 
0be0: 7d 20 76 61 6c 69 64 20 68 74 6d 6c 20 61 74 74  } valid html att
0bf0: 72 69 62 75 74 65 20 6e 61 6d 65 0a 20 2a 2f 0a  ribute name. */.
0c00: 65 78 70 6f 72 74 20 66 75 6e 63 74 69 6f 6e 20  export function 
0c10: 6e 6f 72 6d 61 6c 69 7a 65 41 74 74 72 4e 61 6d  normalizeAttrNam
0c20: 65 28 61 74 74 72 4e 61 6d 65 29 20 7b 0a 20 20  e(attrName) {.  
0c30: 69 66 20 28 21 61 74 74 72 4e 61 6d 65 29 20 72  if (!attrName) r
0c40: 65 74 75 72 6e 20 6e 75 6c 6c 0a 20 20 61 74 74  eturn null.  att
0c50: 72 4e 61 6d 65 20 3d 20 61 74 74 72 4e 61 6d 65  rName = attrName
0c60: 2e 72 65 70 6c 61 63 65 28 41 54 54 52 53 5f 50  .replace(ATTRS_P
0c70: 52 45 46 49 58 2c 20 27 27 29 0a 20 20 69 66 20  REFIX, '').  if 
0c80: 28 43 41 53 45 5f 53 45 4e 53 49 54 49 56 45 5f  (CASE_SENSITIVE_
0c90: 41 54 54 52 49 42 55 54 45 53 5b 61 74 74 72 4e  ATTRIBUTES[attrN
0ca0: 61 6d 65 5d 29 20 61 74 74 72 4e 61 6d 65 20 3d  ame]) attrName =
0cb0: 20 43 41 53 45 5f 53 45 4e 53 49 54 49 56 45 5f   CASE_SENSITIVE_
0cc0: 41 54 54 52 49 42 55 54 45 53 5b 61 74 74 72 4e  ATTRIBUTES[attrN
0cd0: 61 6d 65 5d 0a 20 20 72 65 74 75 72 6e 20 61 74  ame].  return at
0ce0: 74 72 4e 61 6d 65 0a 7d 0a 0a 2f 2a 2a 0a 20 2a  trName.}../**. *
0cf0: 20 55 70 64 61 74 65 20 6f 6e 20 73 69 6e 67 6c   Update on singl
0d00: 65 20 74 61 67 20 65 78 70 72 65 73 73 69 6f 6e  e tag expression
0d10: 0a 20 2a 20 40 74 68 69 73 20 54 61 67 0a 20 2a  . * @this Tag. *
0d20: 20 40 70 61 72 61 6d 20 7b 20 4f 62 6a 65 63 74   @param { Object
0d30: 20 7d 20 65 78 70 72 20 2d 20 65 78 70 72 65 73   } expr - expres
0d40: 73 69 6f 6e 20 6c 6f 67 69 63 0a 20 2a 20 40 72  sion logic. * @r
0d50: 65 74 75 72 6e 73 20 7b 20 75 6e 64 65 66 69 6e  eturns { undefin
0d60: 65 64 20 7d 0a 20 2a 2f 0a 65 78 70 6f 72 74 20  ed }. */.export 
0d70: 66 75 6e 63 74 69 6f 6e 20 75 70 64 61 74 65 45  function updateE
0d80: 78 70 72 65 73 73 69 6f 6e 28 65 78 70 72 29 20  xpression(expr) 
0d90: 7b 0a 20 20 69 66 20 28 74 68 69 73 2e 72 6f 6f  {.  if (this.roo
0da0: 74 20 26 26 20 67 65 74 41 74 74 72 69 62 75 74  t && getAttribut
0db0: 65 28 74 68 69 73 2e 72 6f 6f 74 2c 27 76 69 72  e(this.root,'vir
0dc0: 74 75 61 6c 69 7a 65 64 27 29 29 20 72 65 74 75  tualized')) retu
0dd0: 72 6e 0a 0a 20 20 63 6f 6e 73 74 20 64 6f 6d 20  rn..  const dom 
0de0: 3d 20 65 78 70 72 2e 64 6f 6d 0a 20 20 2f 2f 20  = expr.dom.  // 
0df0: 72 65 6d 6f 76 65 20 74 68 65 20 72 69 6f 74 2d  remove the riot-
0e00: 20 70 72 65 66 69 78 0a 20 20 63 6f 6e 73 74 20   prefix.  const 
0e10: 61 74 74 72 4e 61 6d 65 20 3d 20 6e 6f 72 6d 61  attrName = norma
0e20: 6c 69 7a 65 41 74 74 72 4e 61 6d 65 28 65 78 70  lizeAttrName(exp
0e30: 72 2e 61 74 74 72 29 0a 20 20 63 6f 6e 73 74 20  r.attr).  const 
0e40: 69 73 54 6f 67 67 6c 65 20 3d 20 63 6f 6e 74 61  isToggle = conta
0e50: 69 6e 73 28 5b 53 48 4f 57 5f 44 49 52 45 43 54  ins([SHOW_DIRECT
0e60: 49 56 45 2c 20 48 49 44 45 5f 44 49 52 45 43 54  IVE, HIDE_DIRECT
0e70: 49 56 45 5d 2c 20 61 74 74 72 4e 61 6d 65 29 0a  IVE], attrName).
0e80: 20 20 63 6f 6e 73 74 20 69 73 56 69 72 74 75 61    const isVirtua
0e90: 6c 20 3d 20 65 78 70 72 2e 72 6f 6f 74 20 26 26  l = expr.root &&
0ea0: 20 65 78 70 72 2e 72 6f 6f 74 2e 74 61 67 4e 61   expr.root.tagNa
0eb0: 6d 65 20 3d 3d 3d 20 27 56 49 52 54 55 41 4c 27  me === 'VIRTUAL'
0ec0: 0a 20 20 63 6f 6e 73 74 20 7b 20 69 73 41 6e 6f  .  const { isAno
0ed0: 6e 79 6d 6f 75 73 20 7d 20 3d 20 74 68 69 73 2e  nymous } = this.
0ee0: 5f 5f 0a 20 20 63 6f 6e 73 74 20 70 61 72 65 6e  __.  const paren
0ef0: 74 20 3d 20 64 6f 6d 20 26 26 20 28 65 78 70 72  t = dom && (expr
0f00: 2e 70 61 72 65 6e 74 20 7c 7c 20 64 6f 6d 2e 70  .parent || dom.p
0f10: 61 72 65 6e 74 4e 6f 64 65 29 0a 20 20 63 6f 6e  arentNode).  con
0f20: 73 74 20 7b 20 6b 65 65 70 56 61 6c 75 65 41 74  st { keepValueAt
0f30: 74 72 69 62 75 74 65 73 20 7d 20 3d 20 72 69 6f  tributes } = rio
0f40: 74 53 65 74 74 69 6e 67 73 0a 20 20 2f 2f 20 64  tSettings.  // d
0f50: 65 74 65 63 74 20 74 68 65 20 73 74 79 6c 65 20  etect the style 
0f60: 61 74 74 72 69 62 75 74 65 73 0a 20 20 63 6f 6e  attributes.  con
0f70: 73 74 20 69 73 53 74 79 6c 65 41 74 74 72 20 3d  st isStyleAttr =
0f80: 20 61 74 74 72 4e 61 6d 65 20 3d 3d 3d 20 27 73   attrName === 's
0f90: 74 79 6c 65 27 0a 20 20 63 6f 6e 73 74 20 69 73  tyle'.  const is
0fa0: 43 6c 61 73 73 41 74 74 72 20 3d 20 61 74 74 72  ClassAttr = attr
0fb0: 4e 61 6d 65 20 3d 3d 3d 20 27 63 6c 61 73 73 27  Name === 'class'
0fc0: 0a 20 20 63 6f 6e 73 74 20 69 73 56 61 6c 75 65  .  const isValue
0fd0: 41 74 74 72 20 3d 20 61 74 74 72 4e 61 6d 65 20  Attr = attrName 
0fe0: 3d 3d 3d 20 27 76 61 6c 75 65 27 0a 0a 20 20 6c  === 'value'..  l
0ff0: 65 74 20 76 61 6c 75 65 0a 0a 20 20 2f 2f 20 69  et value..  // i
1000: 66 20 69 74 27 73 20 61 20 74 61 67 20 77 65 20  f it's a tag we 
1010: 63 6f 75 6c 64 20 74 6f 74 61 6c 6c 79 20 73 6b  could totally sk
1020: 69 70 20 74 68 65 20 72 65 73 74 0a 20 20 69 66  ip the rest.  if
1030: 20 28 65 78 70 72 2e 5f 72 69 6f 74 5f 69 64 29   (expr._riot_id)
1040: 20 7b 0a 20 20 20 20 69 66 20 28 65 78 70 72 2e   {.    if (expr.
1050: 5f 5f 2e 77 61 73 43 72 65 61 74 65 64 29 20 7b  __.wasCreated) {
1060: 0a 20 20 20 20 20 20 65 78 70 72 2e 75 70 64 61  .      expr.upda
1070: 74 65 28 29 0a 20 20 20 20 2f 2f 20 69 66 20 69  te().    // if i
1080: 74 20 68 61 73 6e 27 74 20 62 65 65 6e 20 6d 6f  t hasn't been mo
1090: 75 6e 74 65 64 20 79 65 74 2c 20 64 6f 20 74 68  unted yet, do th
10a0: 61 74 20 6e 6f 77 2e 0a 20 20 20 20 7d 20 65 6c  at now..    } el
10b0: 73 65 20 7b 0a 20 20 20 20 20 20 65 78 70 72 2e  se {.      expr.
10c0: 6d 6f 75 6e 74 28 29 0a 20 20 20 20 20 20 69 66  mount().      if
10d0: 20 28 69 73 56 69 72 74 75 61 6c 29 20 7b 0a 20   (isVirtual) {. 
10e0: 20 20 20 20 20 20 20 72 65 70 6c 61 63 65 56 69         replaceVi
10f0: 72 74 75 61 6c 28 65 78 70 72 2c 20 65 78 70 72  rtual(expr, expr
1100: 2e 72 6f 6f 74 29 0a 20 20 20 20 20 20 7d 0a 20  .root).      }. 
1110: 20 20 20 7d 0a 20 20 20 20 72 65 74 75 72 6e 0a     }.    return.
1120: 20 20 7d 0a 0a 20 20 2f 2f 20 69 66 20 74 68 69    }..  // if thi
1130: 73 20 65 78 70 72 65 73 73 69 6f 6e 20 68 61 73  s expression has
1140: 20 74 68 65 20 75 70 64 61 74 65 20 6d 65 74 68   the update meth
1150: 6f 64 20 69 74 20 6d 65 61 6e 73 20 69 74 20 63  od it means it c
1160: 61 6e 20 68 61 6e 64 6c 65 20 74 68 65 20 44 4f  an handle the DO
1170: 4d 20 63 68 61 6e 67 65 73 20 62 79 20 69 74 73  M changes by its
1180: 65 6c 66 0a 20 20 69 66 20 28 65 78 70 72 2e 75  elf.  if (expr.u
1190: 70 64 61 74 65 29 20 72 65 74 75 72 6e 20 65 78  pdate) return ex
11a0: 70 72 2e 75 70 64 61 74 65 28 29 0a 0a 20 20 63  pr.update()..  c
11b0: 6f 6e 73 74 20 63 6f 6e 74 65 78 74 20 3d 20 69  onst context = i
11c0: 73 54 6f 67 67 6c 65 20 26 26 20 21 69 73 41 6e  sToggle && !isAn
11d0: 6f 6e 79 6d 6f 75 73 20 3f 20 69 6e 68 65 72 69  onymous ? inheri
11e0: 74 50 61 72 65 6e 74 50 72 6f 70 73 2e 63 61 6c  tParentProps.cal
11f0: 6c 28 74 68 69 73 29 20 3a 20 74 68 69 73 0a 0a  l(this) : this..
1200: 20 20 2f 2f 20 2e 2e 2e 69 74 20 73 65 65 6d 73    // ...it seems
1210: 20 74 6f 20 62 65 20 61 20 73 69 6d 70 6c 65 20   to be a simple 
1220: 65 78 70 72 65 73 73 69 6f 6e 20 73 6f 20 77 65  expression so we
1230: 20 74 72 79 20 74 6f 20 63 61 6c 63 75 6c 61 74   try to calculat
1240: 65 20 69 74 73 20 76 61 6c 75 65 0a 20 20 76 61  e its value.  va
1250: 6c 75 65 20 3d 20 74 6d 70 6c 28 65 78 70 72 2e  lue = tmpl(expr.
1260: 65 78 70 72 2c 20 63 6f 6e 74 65 78 74 29 0a 0a  expr, context)..
1270: 20 20 63 6f 6e 73 74 20 68 61 73 56 61 6c 75 65    const hasValue
1280: 20 3d 20 21 69 73 42 6c 61 6e 6b 28 76 61 6c 75   = !isBlank(valu
1290: 65 29 0a 20 20 63 6f 6e 73 74 20 69 73 4f 62 6a  e).  const isObj
12a0: 20 3d 20 69 73 4f 62 6a 65 63 74 28 76 61 6c 75   = isObject(valu
12b0: 65 29 0a 0a 20 20 2f 2f 20 63 6f 6e 76 65 72 74  e)..  // convert
12c0: 20 74 68 65 20 73 74 79 6c 65 2f 63 6c 61 73 73   the style/class
12d0: 20 6f 62 6a 65 63 74 73 20 74 6f 20 73 74 72 69   objects to stri
12e0: 6e 67 73 0a 20 20 69 66 20 28 69 73 4f 62 6a 29  ngs.  if (isObj)
12f0: 20 7b 0a 20 20 20 20 69 66 20 28 69 73 43 6c 61   {.    if (isCla
1300: 73 73 41 74 74 72 29 20 7b 0a 20 20 20 20 20 20  ssAttr) {.      
1310: 76 61 6c 75 65 20 3d 20 74 6d 70 6c 28 4a 53 4f  value = tmpl(JSO
1320: 4e 2e 73 74 72 69 6e 67 69 66 79 28 76 61 6c 75  N.stringify(valu
1330: 65 29 2c 20 74 68 69 73 29 0a 20 20 20 20 7d 20  e), this).    } 
1340: 65 6c 73 65 20 69 66 20 28 69 73 53 74 79 6c 65  else if (isStyle
1350: 41 74 74 72 29 20 7b 0a 20 20 20 20 20 20 76 61  Attr) {.      va
1360: 6c 75 65 20 3d 20 73 74 79 6c 65 4f 62 6a 65 63  lue = styleObjec
1370: 74 54 6f 53 74 72 69 6e 67 28 76 61 6c 75 65 29  tToString(value)
1380: 0a 20 20 20 20 7d 0a 20 20 7d 0a 0a 20 20 2f 2f  .    }.  }..  //
1390: 20 72 65 6d 6f 76 65 20 6f 72 69 67 69 6e 61 6c   remove original
13a0: 20 61 74 74 72 69 62 75 74 65 0a 20 20 69 66 20   attribute.  if 
13b0: 28 65 78 70 72 2e 61 74 74 72 20 26 26 0a 20 20  (expr.attr &&.  
13c0: 20 20 20 20 28 0a 20 20 20 20 20 20 20 20 2f 2f      (.        //
13d0: 20 74 68 65 20 6f 72 69 67 69 6e 61 6c 20 61 74   the original at
13e0: 74 72 69 62 75 74 65 20 63 61 6e 20 62 65 20 72  tribute can be r
13f0: 65 6d 6f 76 65 64 20 6f 6e 6c 79 20 69 66 20 77  emoved only if w
1400: 65 20 61 72 65 20 70 61 72 73 69 6e 67 20 74 68  e are parsing th
1410: 65 20 6f 72 69 67 69 6e 61 6c 20 65 78 70 72 65  e original expre
1420: 73 73 69 6f 6e 0a 20 20 20 20 20 20 20 20 21 65  ssion.        !e
1430: 78 70 72 2e 77 61 73 50 61 72 73 65 64 4f 6e 63  xpr.wasParsedOnc
1440: 65 20 7c 7c 0a 20 20 20 20 20 20 20 20 2f 2f 20  e ||.        // 
1450: 6f 72 20 69 74 73 20 76 61 6c 75 65 20 69 73 20  or its value is 
1460: 66 61 6c 73 65 0a 20 20 20 20 20 20 20 20 76 61  false.        va
1470: 6c 75 65 20 3d 3d 3d 20 66 61 6c 73 65 20 7c 7c  lue === false ||
1480: 0a 20 20 20 20 20 20 20 20 2f 2f 20 6f 72 20 69  .        // or i
1490: 66 20 69 74 73 20 76 61 6c 75 65 20 69 73 20 63  f its value is c
14a0: 75 72 72 65 6e 74 6c 79 20 66 61 6c 73 79 2e 2e  urrently falsy..
14b0: 2e 0a 20 20 20 20 20 20 20 20 2f 2f 20 57 65 20  ..        // We 
14c0: 77 69 6c 6c 20 6b 65 65 70 20 74 68 65 20 22 76  will keep the "v
14d0: 61 6c 75 65 22 20 61 74 74 72 69 62 75 74 65 73  alue" attributes
14e0: 20 69 66 20 74 68 65 20 22 6b 65 65 70 56 61 6c   if the "keepVal
14f0: 75 65 41 74 74 72 69 62 75 74 65 73 22 0a 20 20  ueAttributes".  
1500: 20 20 20 20 20 20 2f 2f 20 69 73 20 65 6e 61 62        // is enab
1510: 6c 65 64 20 74 68 6f 75 67 68 0a 20 20 20 20 20  led though.     
1520: 20 20 20 28 21 68 61 73 56 61 6c 75 65 20 26 26     (!hasValue &&
1530: 20 28 21 69 73 56 61 6c 75 65 41 74 74 72 20 7c   (!isValueAttr |
1540: 7c 20 69 73 56 61 6c 75 65 41 74 74 72 20 26 26  | isValueAttr &&
1550: 20 21 6b 65 65 70 56 61 6c 75 65 41 74 74 72 69   !keepValueAttri
1560: 62 75 74 65 73 29 29 0a 20 20 20 20 20 20 29 0a  butes)).      ).
1570: 20 20 29 20 7b 0a 20 20 20 20 2f 2f 20 72 65 6d    ) {.    // rem
1580: 6f 76 65 20 65 69 74 68 65 72 20 72 69 6f 74 2d  ove either riot-
1590: 2a 20 61 74 74 72 69 62 75 74 65 73 20 6f 72 20  * attributes or 
15a0: 6a 75 73 74 20 74 68 65 20 61 74 74 72 69 62 75  just the attribu
15b0: 74 65 20 6e 61 6d 65 0a 20 20 20 20 72 65 6d 6f  te name.    remo
15c0: 76 65 41 74 74 72 69 62 75 74 65 28 64 6f 6d 2c  veAttribute(dom,
15d0: 20 67 65 74 41 74 74 72 69 62 75 74 65 28 64 6f   getAttribute(do
15e0: 6d 2c 20 65 78 70 72 2e 61 74 74 72 29 20 3f 20  m, expr.attr) ? 
15f0: 65 78 70 72 2e 61 74 74 72 20 3a 20 61 74 74 72  expr.attr : attr
1600: 4e 61 6d 65 29 0a 20 20 7d 0a 0a 20 20 2f 2f 20  Name).  }..  // 
1610: 66 6f 72 20 74 68 65 20 62 6f 6f 6c 65 61 6e 20  for the boolean 
1620: 61 74 74 72 69 62 75 74 65 73 20 77 65 20 64 6f  attributes we do
1630: 6e 27 74 20 6e 65 65 64 20 74 68 65 20 76 61 6c  n't need the val
1640: 75 65 0a 20 20 2f 2f 20 77 65 20 63 61 6e 20 63  ue.  // we can c
1650: 6f 6e 76 65 72 74 20 69 74 20 74 6f 20 63 68 65  onvert it to che
1660: 63 6b 65 64 3d 74 72 75 65 20 74 6f 20 63 68 65  cked=true to che
1670: 63 6b 65 64 3d 63 68 65 63 6b 65 64 0a 20 20 69  cked=checked.  i
1680: 66 20 28 65 78 70 72 2e 62 6f 6f 6c 29 20 76 61  f (expr.bool) va
1690: 6c 75 65 20 3d 20 76 61 6c 75 65 20 3f 20 61 74  lue = value ? at
16a0: 74 72 4e 61 6d 65 20 3a 20 66 61 6c 73 65 0a 20  trName : false. 
16b0: 20 69 66 20 28 65 78 70 72 2e 69 73 52 74 61 67   if (expr.isRtag
16c0: 29 20 72 65 74 75 72 6e 20 75 70 64 61 74 65 44  ) return updateD
16d0: 61 74 61 49 73 28 65 78 70 72 2c 20 74 68 69 73  ataIs(expr, this
16e0: 2c 20 76 61 6c 75 65 29 0a 20 20 69 66 20 28 65  , value).  if (e
16f0: 78 70 72 2e 77 61 73 50 61 72 73 65 64 4f 6e 63  xpr.wasParsedOnc
1700: 65 20 26 26 20 65 78 70 72 2e 76 61 6c 75 65 20  e && expr.value 
1710: 3d 3d 3d 20 76 61 6c 75 65 29 20 72 65 74 75 72  === value) retur
1720: 6e 0a 0a 20 20 2f 2f 20 75 70 64 61 74 65 20 74  n..  // update t
1730: 68 65 20 65 78 70 72 65 73 73 69 6f 6e 20 76 61  he expression va
1740: 6c 75 65 0a 20 20 65 78 70 72 2e 76 61 6c 75 65  lue.  expr.value
1750: 20 3d 20 76 61 6c 75 65 0a 20 20 65 78 70 72 2e   = value.  expr.
1760: 77 61 73 50 61 72 73 65 64 4f 6e 63 65 20 3d 20  wasParsedOnce = 
1770: 74 72 75 65 0a 0a 20 20 2f 2f 20 69 66 20 74 68  true..  // if th
1780: 65 20 76 61 6c 75 65 20 69 73 20 61 6e 20 6f 62  e value is an ob
1790: 6a 65 63 74 20 28 61 6e 64 20 69 74 27 73 20 6e  ject (and it's n
17a0: 6f 74 20 61 20 73 74 79 6c 65 20 6f 72 20 63 6c  ot a style or cl
17b0: 61 73 73 20 61 74 74 72 69 62 75 74 65 29 20 77  ass attribute) w
17c0: 65 20 63 61 6e 20 6e 6f 74 20 64 6f 20 6d 75 63  e can not do muc
17d0: 68 20 6d 6f 72 65 20 77 69 74 68 20 69 74 0a 20  h more with it. 
17e0: 20 69 66 20 28 69 73 4f 62 6a 20 26 26 20 21 69   if (isObj && !i
17f0: 73 43 6c 61 73 73 41 74 74 72 20 26 26 20 21 69  sClassAttr && !i
1800: 73 53 74 79 6c 65 41 74 74 72 20 26 26 20 21 69  sStyleAttr && !i
1810: 73 54 6f 67 67 6c 65 29 20 72 65 74 75 72 6e 0a  sToggle) return.
1820: 20 20 2f 2f 20 61 76 6f 69 64 20 74 6f 20 72 65    // avoid to re
1830: 6e 64 65 72 20 75 6e 64 65 66 69 6e 65 64 2f 6e  nder undefined/n
1840: 75 6c 6c 20 76 61 6c 75 65 73 0a 20 20 69 66 20  ull values.  if 
1850: 28 21 68 61 73 56 61 6c 75 65 29 20 76 61 6c 75  (!hasValue) valu
1860: 65 20 3d 20 27 27 0a 0a 20 20 2f 2f 20 74 65 78  e = ''..  // tex
1870: 74 61 72 65 61 20 61 6e 64 20 74 65 78 74 20 6e  tarea and text n
1880: 6f 64 65 73 20 68 61 76 65 20 6e 6f 20 61 74 74  odes have no att
1890: 72 69 62 75 74 65 20 6e 61 6d 65 0a 20 20 69 66  ribute name.  if
18a0: 20 28 21 61 74 74 72 4e 61 6d 65 29 20 7b 0a 20   (!attrName) {. 
18b0: 20 20 20 2f 2f 20 61 62 6f 75 74 20 23 38 31 35     // about #815
18c0: 20 77 2f 6f 20 72 65 70 6c 61 63 65 3a 20 74 68   w/o replace: th
18d0: 65 20 62 72 6f 77 73 65 72 20 63 6f 6e 76 65 72  e browser conver
18e0: 74 73 20 74 68 65 20 76 61 6c 75 65 20 74 6f 20  ts the value to 
18f0: 61 20 73 74 72 69 6e 67 2c 0a 20 20 20 20 2f 2f  a string,.    //
1900: 20 74 68 65 20 63 6f 6d 70 61 72 69 73 6f 6e 20   the comparison 
1910: 62 79 20 22 3d 3d 22 20 64 6f 65 73 20 74 6f 6f  by "==" does too
1920: 2c 20 62 75 74 20 6e 6f 74 20 69 6e 20 74 68 65  , but not in the
1930: 20 73 65 72 76 65 72 0a 20 20 20 20 76 61 6c 75   server.    valu
1940: 65 20 2b 3d 20 27 27 0a 20 20 20 20 2f 2f 20 74  e += ''.    // t
1950: 65 73 74 20 66 6f 72 20 70 61 72 65 6e 74 20 61  est for parent a
1960: 76 6f 69 64 73 20 65 72 72 6f 72 20 77 69 74 68  voids error with
1970: 20 69 6e 76 61 6c 69 64 20 61 73 73 69 67 6e 6d   invalid assignm
1980: 65 6e 74 20 74 6f 20 6e 6f 64 65 56 61 6c 75 65  ent to nodeValue
1990: 0a 20 20 20 20 69 66 20 28 70 61 72 65 6e 74 29  .    if (parent)
19a0: 20 7b 0a 20 20 20 20 20 20 2f 2f 20 63 61 63 68   {.      // cach
19b0: 65 20 74 68 65 20 70 61 72 65 6e 74 20 6e 6f 64  e the parent nod
19c0: 65 20 62 65 63 61 75 73 65 20 73 6f 6d 65 68 6f  e because someho
19d0: 77 20 69 74 20 77 69 6c 6c 20 62 65 63 6f 6d 65  w it will become
19e0: 20 6e 75 6c 6c 20 6f 6e 20 49 45 0a 20 20 20 20   null on IE.    
19f0: 20 20 2f 2f 20 6f 6e 20 74 68 65 20 6e 65 78 74    // on the next
1a00: 20 69 74 65 72 61 74 69 6f 6e 0a 20 20 20 20 20   iteration.     
1a10: 20 65 78 70 72 2e 70 61 72 65 6e 74 20 3d 20 70   expr.parent = p
1a20: 61 72 65 6e 74 0a 20 20 20 20 20 20 69 66 20 28  arent.      if (
1a30: 70 61 72 65 6e 74 2e 74 61 67 4e 61 6d 65 20 3d  parent.tagName =
1a40: 3d 3d 20 27 54 45 58 54 41 52 45 41 27 29 20 7b  == 'TEXTAREA') {
1a50: 0a 20 20 20 20 20 20 20 20 70 61 72 65 6e 74 2e  .        parent.
1a60: 76 61 6c 75 65 20 3d 20 76 61 6c 75 65 20 20 20  value = value   
1a70: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
1a80: 20 2f 2f 20 23 31 31 31 33 0a 20 20 20 20 20 20   // #1113.      
1a90: 20 20 69 66 20 28 21 49 45 5f 56 45 52 53 49 4f    if (!IE_VERSIO
1aa0: 4e 29 20 64 6f 6d 2e 6e 6f 64 65 56 61 6c 75 65  N) dom.nodeValue
1ab0: 20 3d 20 76 61 6c 75 65 20 20 2f 2f 20 23 31 36   = value  // #16
1ac0: 32 35 20 49 45 20 74 68 72 6f 77 73 20 68 65 72  25 IE throws her
1ad0: 65 2c 20 6e 6f 64 65 56 61 6c 75 65 0a 20 20 20  e, nodeValue.   
1ae0: 20 20 20 7d 20 20 20 20 20 20 20 20 20 20 20 20     }            
1af0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
1b00: 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20               // 
1b10: 77 69 6c 6c 20 62 65 20 61 76 61 69 6c 61 62 6c  will be availabl
1b20: 65 20 6f 6e 20 27 75 70 64 61 74 65 64 27 0a 20  e on 'updated'. 
1b30: 20 20 20 20 20 65 6c 73 65 20 64 6f 6d 2e 6e 6f       else dom.no
1b40: 64 65 56 61 6c 75 65 20 3d 20 76 61 6c 75 65 0a  deValue = value.
1b50: 20 20 20 20 7d 0a 20 20 20 20 72 65 74 75 72 6e      }.    return
1b60: 0a 20 20 7d 0a 0a 20 20 73 77 69 74 63 68 20 28  .  }..  switch (
1b70: 74 72 75 65 29 20 7b 0a 20 20 2f 2f 20 68 61 6e  true) {.  // han
1b80: 64 6c 65 20 65 76 65 6e 74 73 20 62 69 6e 64 69  dle events bindi
1b90: 6e 67 0a 20 20 63 61 73 65 20 69 73 46 75 6e 63  ng.  case isFunc
1ba0: 74 69 6f 6e 28 76 61 6c 75 65 29 3a 0a 20 20 20  tion(value):.   
1bb0: 20 69 66 20 28 69 73 45 76 65 6e 74 41 74 74 72   if (isEventAttr
1bc0: 69 62 75 74 65 28 61 74 74 72 4e 61 6d 65 29 29  ibute(attrName))
1bd0: 20 7b 0a 20 20 20 20 20 20 73 65 74 45 76 65 6e   {.      setEven
1be0: 74 48 61 6e 64 6c 65 72 28 61 74 74 72 4e 61 6d  tHandler(attrNam
1bf0: 65 2c 20 76 61 6c 75 65 2c 20 64 6f 6d 2c 20 74  e, value, dom, t
1c00: 68 69 73 29 0a 20 20 20 20 7d 0a 20 20 20 20 62  his).    }.    b
1c10: 72 65 61 6b 0a 20 20 2f 2f 20 73 68 6f 77 20 2f  reak.  // show /
1c20: 20 68 69 64 65 0a 20 20 63 61 73 65 20 69 73 54   hide.  case isT
1c30: 6f 67 67 6c 65 3a 0a 20 20 20 20 74 6f 67 67 6c  oggle:.    toggl
1c40: 65 56 69 73 69 62 69 6c 69 74 79 28 64 6f 6d 2c  eVisibility(dom,
1c50: 20 61 74 74 72 4e 61 6d 65 20 3d 3d 3d 20 48 49   attrName === HI
1c60: 44 45 5f 44 49 52 45 43 54 49 56 45 20 3f 20 21  DE_DIRECTIVE ? !
1c70: 76 61 6c 75 65 20 3a 20 76 61 6c 75 65 29 0a 20  value : value). 
1c80: 20 20 20 62 72 65 61 6b 0a 20 20 2f 2f 20 68 61     break.  // ha
1c90: 6e 64 6c 65 20 61 74 74 72 69 62 75 74 65 73 0a  ndle attributes.
1ca0: 20 20 64 65 66 61 75 6c 74 3a 0a 20 20 20 20 69    default:.    i
1cb0: 66 20 28 65 78 70 72 2e 62 6f 6f 6c 29 20 7b 0a  f (expr.bool) {.
1cc0: 20 20 20 20 20 20 64 6f 6d 5b 61 74 74 72 4e 61        dom[attrNa
1cd0: 6d 65 5d 20 3d 20 76 61 6c 75 65 0a 20 20 20 20  me] = value.    
1ce0: 7d 0a 0a 20 20 20 20 69 66 20 28 69 73 56 61 6c  }..    if (isVal
1cf0: 75 65 41 74 74 72 20 26 26 20 64 6f 6d 2e 76 61  ueAttr && dom.va
1d00: 6c 75 65 20 21 3d 3d 20 76 61 6c 75 65 29 20 7b  lue !== value) {
1d10: 0a 20 20 20 20 20 20 64 6f 6d 2e 76 61 6c 75 65  .      dom.value
1d20: 20 3d 20 76 61 6c 75 65 0a 20 20 20 20 7d 20 65   = value.    } e
1d30: 6c 73 65 20 69 66 20 28 68 61 73 56 61 6c 75 65  lse if (hasValue
1d40: 20 26 26 20 76 61 6c 75 65 20 21 3d 3d 20 66 61   && value !== fa
1d50: 6c 73 65 29 20 7b 0a 20 20 20 20 20 20 73 65 74  lse) {.      set
1d60: 41 74 74 72 69 62 75 74 65 28 64 6f 6d 2c 20 61  Attribute(dom, a
1d70: 74 74 72 4e 61 6d 65 2c 20 76 61 6c 75 65 29 0a  ttrName, value).
1d80: 20 20 20 20 7d 0a 0a 20 20 20 20 2f 2f 20 6d 61      }..    // ma
1d90: 6b 65 20 73 75 72 65 20 74 68 61 74 20 69 6e 20  ke sure that in 
1da0: 63 61 73 65 20 6f 66 20 73 74 79 6c 65 20 63 68  case of style ch
1db0: 61 6e 67 65 73 0a 20 20 20 20 2f 2f 20 74 68 65  anges.    // the
1dc0: 20 65 6c 65 6d 65 6e 74 20 73 74 61 79 73 20 68   element stays h
1dd0: 69 64 64 65 6e 0a 20 20 20 20 69 66 20 28 69 73  idden.    if (is
1de0: 53 74 79 6c 65 41 74 74 72 20 26 26 20 64 6f 6d  StyleAttr && dom
1df0: 2e 68 69 64 64 65 6e 29 20 74 6f 67 67 6c 65 56  .hidden) toggleV
1e00: 69 73 69 62 69 6c 69 74 79 28 64 6f 6d 2c 20 66  isibility(dom, f
1e10: 61 6c 73 65 29 0a 20 20 7d 0a 7d 0a 0a 2f 2a 2a  alse).  }.}../**
1e20: 0a 20 2a 20 55 70 64 61 74 65 20 61 6c 6c 20 74  . * Update all t
1e30: 68 65 20 65 78 70 72 65 73 73 69 6f 6e 73 20 69  he expressions i
1e40: 6e 20 61 20 54 61 67 20 69 6e 73 74 61 6e 63 65  n a Tag instance
1e50: 0a 20 2a 20 40 74 68 69 73 20 54 61 67 0a 20 2a  . * @this Tag. *
1e60: 20 40 70 61 72 61 6d 20 7b 20 41 72 72 61 79 20   @param { Array 
1e70: 7d 20 65 78 70 72 65 73 73 69 6f 6e 73 20 2d 20  } expressions - 
1e80: 65 78 70 72 65 73 73 69 6f 6e 20 74 68 61 74 20  expression that 
1e90: 6d 75 73 74 20 62 65 20 72 65 20 65 76 61 6c 75  must be re evalu
1ea0: 61 74 65 64 0a 20 2a 2f 0a 65 78 70 6f 72 74 20  ated. */.export 
1eb0: 64 65 66 61 75 6c 74 20 66 75 6e 63 74 69 6f 6e  default function
1ec0: 20 75 70 64 61 74 65 28 65 78 70 72 65 73 73 69   update(expressi
1ed0: 6f 6e 73 29 20 7b 0a 20 20 65 61 63 68 28 65 78  ons) {.  each(ex
1ee0: 70 72 65 73 73 69 6f 6e 73 2c 20 75 70 64 61 74  pressions, updat
1ef0: 65 45 78 70 72 65 73 73 69 6f 6e 2e 62 69 6e 64  eExpression.bind
1f00: 28 74 68 69 73 29 29 0a 7d 0a                    (this)).}.