0000: 69 6d 70 6f 72 74 20 5f 65 61 63 68 20 66 72 6f import _each fro
0010: 6d 20 27 2e 2f 65 61 63 68 27 0a 69 6d 70 6f 72 m './each'.impor
0020: 74 20 7b 20 74 6d 70 6c 20 7d 20 66 72 6f 6d 20 t { tmpl } from
0030: 27 72 69 6f 74 2d 74 6d 70 6c 27 0a 69 6d 70 6f 'riot-tmpl'.impo
0040: 72 74 20 7b 0a 20 20 43 4f 4e 44 49 54 49 4f 4e rt {. CONDITION
0050: 41 4c 5f 44 49 52 45 43 54 49 56 45 2c 0a 20 20 AL_DIRECTIVE,.
0060: 4c 4f 4f 50 5f 44 49 52 45 43 54 49 56 45 2c 0a LOOP_DIRECTIVE,.
0070: 20 20 49 53 5f 44 49 52 45 43 54 49 56 45 2c 0a IS_DIRECTIVE,.
0080: 20 20 52 45 46 5f 44 49 52 45 43 54 49 56 45 53 REF_DIRECTIVES
0090: 2c 0a 20 20 59 49 45 4c 44 5f 54 41 47 0a 7d 20 ,. YIELD_TAG.}
00a0: 66 72 6f 6d 20 27 2e 2f 2e 2e 2f 63 6f 6d 6d 6f from './../commo
00b0: 6e 2f 67 6c 6f 62 61 6c 2d 76 61 72 69 61 62 6c n/global-variabl
00c0: 65 73 27 0a 0a 69 6d 70 6f 72 74 20 63 72 65 61 es'..import crea
00d0: 74 65 52 65 66 44 69 72 65 63 74 69 76 65 20 66 teRefDirective f
00e0: 72 6f 6d 20 27 2e 2f 2e 2e 2f 63 6f 6d 6d 6f 6e rom './../common
00f0: 2f 75 74 69 6c 2f 74 61 67 73 2f 63 72 65 61 74 /util/tags/creat
0100: 65 2d 72 65 66 2d 64 69 72 65 63 74 69 76 65 27 e-ref-directive'
0110: 0a 69 6d 70 6f 72 74 20 63 72 65 61 74 65 49 66 .import createIf
0120: 44 69 72 65 63 74 69 76 65 20 66 72 6f 6d 20 27 Directive from '
0130: 2e 2f 2e 2e 2f 63 6f 6d 6d 6f 6e 2f 75 74 69 6c ./../common/util
0140: 2f 74 61 67 73 2f 63 72 65 61 74 65 2d 69 66 2d /tags/create-if-
0150: 64 69 72 65 63 74 69 76 65 27 0a 69 6d 70 6f 72 directive'.impor
0160: 74 20 69 73 42 6f 6f 6c 41 74 74 72 20 66 72 6f t isBoolAttr fro
0170: 6d 20 27 2e 2f 2e 2e 2f 63 6f 6d 6d 6f 6e 2f 75 m './../common/u
0180: 74 69 6c 2f 63 68 65 63 6b 73 2f 69 73 2d 62 6f til/checks/is-bo
0190: 6f 6c 65 61 6e 2d 61 74 74 72 69 62 75 74 65 27 olean-attribute'
01a0: 0a 69 6d 70 6f 72 74 20 77 61 6c 6b 4e 6f 64 65 .import walkNode
01b0: 73 20 66 72 6f 6d 20 27 2e 2f 2e 2e 2f 63 6f 6d s from './../com
01c0: 6d 6f 6e 2f 75 74 69 6c 2f 64 6f 6d 2f 77 61 6c mon/util/dom/wal
01d0: 6b 2d 6e 6f 64 65 73 27 0a 69 6d 70 6f 72 74 20 k-nodes'.import
01e0: 67 65 74 41 74 74 72 69 62 75 74 65 20 66 72 6f getAttribute fro
01f0: 6d 20 27 2e 2f 2e 2e 2f 63 6f 6d 6d 6f 6e 2f 75 m './../common/u
0200: 74 69 6c 2f 64 6f 6d 2f 67 65 74 2d 61 74 74 72 til/dom/get-attr
0210: 69 62 75 74 65 27 0a 69 6d 70 6f 72 74 20 73 65 ibute'.import se
0220: 74 41 74 74 72 69 62 75 74 65 20 66 72 6f 6d 20 tAttribute from
0230: 27 2e 2f 2e 2e 2f 63 6f 6d 6d 6f 6e 2f 75 74 69 './../common/uti
0240: 6c 2f 64 6f 6d 2f 73 65 74 2d 61 74 74 72 69 62 l/dom/set-attrib
0250: 75 74 65 27 0a 69 6d 70 6f 72 74 20 65 61 63 68 ute'.import each
0260: 20 66 72 6f 6d 20 27 2e 2f 2e 2e 2f 63 6f 6d 6d from './../comm
0270: 6f 6e 2f 75 74 69 6c 2f 6d 69 73 63 2f 65 61 63 on/util/misc/eac
0280: 68 27 0a 69 6d 70 6f 72 74 20 63 6f 6e 74 61 69 h'.import contai
0290: 6e 73 20 66 72 6f 6d 20 27 2e 2f 2e 2e 2f 63 6f ns from './../co
02a0: 6d 6d 6f 6e 2f 75 74 69 6c 2f 6d 69 73 63 2f 63 mmon/util/misc/c
02b0: 6f 6e 74 61 69 6e 73 27 0a 69 6d 70 6f 72 74 20 ontains'.import
02c0: 77 61 72 6e 20 66 72 6f 6d 20 27 2e 2f 2e 2e 2f warn from './../
02d0: 63 6f 6d 6d 6f 6e 2f 75 74 69 6c 2f 6d 69 73 63 common/util/misc
02e0: 2f 77 61 72 6e 27 0a 69 6d 70 6f 72 74 20 67 65 /warn'.import ge
02f0: 74 54 61 67 20 66 72 6f 6d 20 27 2e 2f 2e 2e 2f tTag from './../
0300: 63 6f 6d 6d 6f 6e 2f 75 74 69 6c 2f 74 61 67 73 common/util/tags
0310: 2f 67 65 74 27 0a 69 6d 70 6f 72 74 20 69 6e 69 /get'.import ini
0320: 74 43 68 69 6c 64 20 66 72 6f 6d 20 27 2e 2f 2e tChild from './.
0330: 2e 2f 63 6f 6d 6d 6f 6e 2f 75 74 69 6c 2f 74 61 ./common/util/ta
0340: 67 73 2f 69 6e 69 74 2d 63 68 69 6c 64 27 0a 69 gs/init-child'.i
0350: 6d 70 6f 72 74 20 63 72 65 61 74 65 54 61 67 20 mport createTag
0360: 66 72 6f 6d 20 27 2e 2f 74 61 67 27 0a 0a 2f 2a from './tag'../*
0370: 2a 0a 20 2a 20 57 61 6c 6b 20 74 68 65 20 74 61 *. * Walk the ta
0380: 67 20 44 4f 4d 20 74 6f 20 64 65 74 65 63 74 20 g DOM to detect
0390: 74 68 65 20 65 78 70 72 65 73 73 69 6f 6e 73 20 the expressions
03a0: 74 6f 20 65 76 61 6c 75 61 74 65 0a 20 2a 20 40 to evaluate. * @
03b0: 74 68 69 73 20 54 61 67 0a 20 2a 20 40 70 61 72 this Tag. * @par
03c0: 61 6d 20 20 20 7b 20 48 54 4d 4c 45 6c 65 6d 65 am { HTMLEleme
03d0: 6e 74 20 7d 20 72 6f 6f 74 20 2d 20 72 6f 6f 74 nt } root - root
03e0: 20 74 61 67 20 77 68 65 72 65 20 77 65 20 77 69 tag where we wi
03f0: 6c 6c 20 73 74 61 72 74 20 64 69 67 67 69 6e 67 ll start digging
0400: 20 74 68 65 20 65 78 70 72 65 73 73 69 6f 6e 73 the expressions
0410: 0a 20 2a 20 40 70 61 72 61 6d 20 20 20 7b 20 42 . * @param { B
0420: 6f 6f 6c 65 61 6e 20 7d 20 6d 75 73 74 49 6e 63 oolean } mustInc
0430: 6c 75 64 65 52 6f 6f 74 20 2d 20 66 6c 61 67 20 ludeRoot - flag
0440: 74 6f 20 64 65 63 69 64 65 20 77 68 65 74 68 65 to decide whethe
0450: 72 20 74 68 65 20 72 6f 6f 74 20 6d 75 73 74 20 r the root must
0460: 62 65 20 70 61 72 73 65 64 20 61 73 20 77 65 6c be parsed as wel
0470: 6c 0a 20 2a 20 40 72 65 74 75 72 6e 73 20 7b 20 l. * @returns {
0480: 41 72 72 61 79 20 7d 20 61 6c 6c 20 74 68 65 20 Array } all the
0490: 65 78 70 72 65 73 73 69 6f 6e 73 20 66 6f 75 6e expressions foun
04a0: 64 0a 20 2a 2f 0a 65 78 70 6f 72 74 20 66 75 6e d. */.export fun
04b0: 63 74 69 6f 6e 20 70 61 72 73 65 45 78 70 72 65 ction parseExpre
04c0: 73 73 69 6f 6e 73 28 72 6f 6f 74 2c 20 6d 75 73 ssions(root, mus
04d0: 74 49 6e 63 6c 75 64 65 52 6f 6f 74 29 20 7b 0a tIncludeRoot) {.
04e0: 20 20 63 6f 6e 73 74 20 65 78 70 72 65 73 73 69 const expressi
04f0: 6f 6e 73 20 3d 20 5b 5d 0a 0a 20 20 77 61 6c 6b ons = [].. walk
0500: 4e 6f 64 65 73 28 72 6f 6f 74 2c 20 28 64 6f 6d Nodes(root, (dom
0510: 29 20 3d 3e 20 7b 0a 20 20 20 20 63 6f 6e 73 74 ) => {. const
0520: 20 74 79 70 65 20 3d 20 64 6f 6d 2e 6e 6f 64 65 type = dom.node
0530: 54 79 70 65 0a 20 20 20 20 6c 65 74 20 61 74 74 Type. let att
0540: 72 0a 20 20 20 20 6c 65 74 20 74 61 67 49 6d 70 r. let tagImp
0550: 6c 0a 0a 20 20 20 20 69 66 20 28 21 6d 75 73 74 l.. if (!must
0560: 49 6e 63 6c 75 64 65 52 6f 6f 74 20 26 26 20 64 IncludeRoot && d
0570: 6f 6d 20 3d 3d 3d 20 72 6f 6f 74 29 20 72 65 74 om === root) ret
0580: 75 72 6e 0a 0a 20 20 20 20 2f 2f 20 74 65 78 74 urn.. // text
0590: 20 6e 6f 64 65 0a 20 20 20 20 69 66 20 28 74 79 node. if (ty
05a0: 70 65 20 3d 3d 3d 20 33 20 26 26 20 64 6f 6d 2e pe === 3 && dom.
05b0: 70 61 72 65 6e 74 4e 6f 64 65 2e 74 61 67 4e 61 parentNode.tagNa
05c0: 6d 65 20 21 3d 3d 20 27 53 54 59 4c 45 27 20 26 me !== 'STYLE' &
05d0: 26 20 74 6d 70 6c 2e 68 61 73 45 78 70 72 28 64 & tmpl.hasExpr(d
05e0: 6f 6d 2e 6e 6f 64 65 56 61 6c 75 65 29 29 0a 20 om.nodeValue)).
05f0: 20 20 20 20 20 65 78 70 72 65 73 73 69 6f 6e 73 expressions
0600: 2e 70 75 73 68 28 7b 64 6f 6d 2c 20 65 78 70 72 .push({dom, expr
0610: 3a 20 64 6f 6d 2e 6e 6f 64 65 56 61 6c 75 65 7d : dom.nodeValue}
0620: 29 0a 0a 20 20 20 20 69 66 20 28 74 79 70 65 20 ).. if (type
0630: 21 3d 3d 20 31 29 20 72 65 74 75 72 6e 0a 0a 20 !== 1) return..
0640: 20 20 20 63 6f 6e 73 74 20 69 73 56 69 72 74 75 const isVirtu
0650: 61 6c 20 3d 20 64 6f 6d 2e 74 61 67 4e 61 6d 65 al = dom.tagName
0660: 20 3d 3d 3d 20 27 56 49 52 54 55 41 4c 27 0a 0a === 'VIRTUAL'..
0670: 20 20 20 20 2f 2f 20 6c 6f 6f 70 2e 20 65 61 63 // loop. eac
0680: 68 20 64 6f 65 73 20 69 74 27 73 20 6f 77 6e 20 h does it's own
0690: 74 68 69 6e 67 20 28 66 6f 72 20 6e 6f 77 29 0a thing (for now).
06a0: 20 20 20 20 69 66 20 28 61 74 74 72 20 3d 20 67 if (attr = g
06b0: 65 74 41 74 74 72 69 62 75 74 65 28 64 6f 6d 2c etAttribute(dom,
06c0: 20 4c 4f 4f 50 5f 44 49 52 45 43 54 49 56 45 29 LOOP_DIRECTIVE)
06d0: 29 20 7b 0a 20 20 20 20 20 20 69 66 28 69 73 56 ) {. if(isV
06e0: 69 72 74 75 61 6c 29 20 73 65 74 41 74 74 72 69 irtual) setAttri
06f0: 62 75 74 65 28 64 6f 6d 2c 20 27 6c 6f 6f 70 56 bute(dom, 'loopV
0700: 69 72 74 75 61 6c 27 2c 20 74 72 75 65 29 20 2f irtual', true) /
0710: 2f 20 69 67 6e 6f 72 65 20 68 65 72 65 2c 20 68 / ignore here, h
0720: 61 6e 64 6c 65 64 20 69 6e 20 5f 65 61 63 68 0a andled in _each.
0730: 20 20 20 20 20 20 65 78 70 72 65 73 73 69 6f 6e expression
0740: 73 2e 70 75 73 68 28 5f 65 61 63 68 28 64 6f 6d s.push(_each(dom
0750: 2c 20 74 68 69 73 2c 20 61 74 74 72 29 29 0a 20 , this, attr)).
0760: 20 20 20 20 20 72 65 74 75 72 6e 20 66 61 6c 73 return fals
0770: 65 0a 20 20 20 20 7d 0a 0a 20 20 20 20 2f 2f 20 e. }.. //
0780: 69 66 2d 61 74 74 72 73 20 62 65 63 6f 6d 65 20 if-attrs become
0790: 74 68 65 20 6e 65 77 20 70 61 72 65 6e 74 2e 20 the new parent.
07a0: 41 6e 79 20 66 6f 6c 6c 6f 77 69 6e 67 20 65 78 Any following ex
07b0: 70 72 65 73 73 69 6f 6e 73 20 28 65 69 74 68 65 pressions (eithe
07c0: 72 20 6f 6e 20 74 68 65 20 63 75 72 72 65 6e 74 r on the current
07d0: 0a 20 20 20 20 2f 2f 20 65 6c 65 6d 65 6e 74 2c . // element,
07e0: 20 6f 72 20 62 65 6c 6f 77 20 69 74 29 20 62 65 or below it) be
07f0: 63 6f 6d 65 20 63 68 69 6c 64 72 65 6e 20 6f 66 come children of
0800: 20 74 68 69 73 20 65 78 70 72 65 73 73 69 6f 6e this expression
0810: 2e 0a 20 20 20 20 69 66 20 28 61 74 74 72 20 3d .. if (attr =
0820: 20 67 65 74 41 74 74 72 69 62 75 74 65 28 64 6f getAttribute(do
0830: 6d 2c 20 43 4f 4e 44 49 54 49 4f 4e 41 4c 5f 44 m, CONDITIONAL_D
0840: 49 52 45 43 54 49 56 45 29 29 20 7b 0a 20 20 20 IRECTIVE)) {.
0850: 20 20 20 65 78 70 72 65 73 73 69 6f 6e 73 2e 70 expressions.p
0860: 75 73 68 28 63 72 65 61 74 65 49 66 44 69 72 65 ush(createIfDire
0870: 63 74 69 76 65 28 64 6f 6d 2c 20 74 68 69 73 2c ctive(dom, this,
0880: 20 61 74 74 72 29 29 0a 20 20 20 20 20 20 72 65 attr)). re
0890: 74 75 72 6e 20 66 61 6c 73 65 0a 20 20 20 20 7d turn false. }
08a0: 0a 0a 20 20 20 20 69 66 20 28 61 74 74 72 20 3d .. if (attr =
08b0: 20 67 65 74 41 74 74 72 69 62 75 74 65 28 64 6f getAttribute(do
08c0: 6d 2c 20 49 53 5f 44 49 52 45 43 54 49 56 45 29 m, IS_DIRECTIVE)
08d0: 29 20 7b 0a 20 20 20 20 20 20 69 66 20 28 74 6d ) {. if (tm
08e0: 70 6c 2e 68 61 73 45 78 70 72 28 61 74 74 72 29 pl.hasExpr(attr)
08f0: 29 20 7b 0a 20 20 20 20 20 20 20 20 65 78 70 72 ) {. expr
0900: 65 73 73 69 6f 6e 73 2e 70 75 73 68 28 7b 0a 20 essions.push({.
0910: 20 20 20 20 20 20 20 20 20 69 73 52 74 61 67 3a isRtag:
0920: 20 74 72 75 65 2c 0a 20 20 20 20 20 20 20 20 20 true,.
0930: 20 65 78 70 72 3a 20 61 74 74 72 2c 0a 20 20 20 expr: attr,.
0940: 20 20 20 20 20 20 20 64 6f 6d 2c 0a 20 20 20 20 dom,.
0950: 20 20 20 20 20 20 61 74 74 72 73 3a 20 5b 5d 2e attrs: [].
0960: 73 6c 69 63 65 2e 63 61 6c 6c 28 64 6f 6d 2e 61 slice.call(dom.a
0970: 74 74 72 69 62 75 74 65 73 29 0a 20 20 20 20 20 ttributes).
0980: 20 20 20 7d 29 0a 0a 20 20 20 20 20 20 20 20 72 }).. r
0990: 65 74 75 72 6e 20 66 61 6c 73 65 0a 20 20 20 20 eturn false.
09a0: 20 20 7d 0a 20 20 20 20 7d 0a 0a 20 20 20 20 2f }. }.. /
09b0: 2f 20 69 66 20 74 68 69 73 20 69 73 20 61 20 74 / if this is a t
09c0: 61 67 2c 20 73 74 6f 70 20 74 72 61 76 65 72 73 ag, stop travers
09d0: 69 6e 67 20 68 65 72 65 2e 0a 20 20 20 20 2f 2f ing here.. //
09e0: 20 77 65 20 69 67 6e 6f 72 65 20 74 68 65 20 72 we ignore the r
09f0: 6f 6f 74 2c 20 73 69 6e 63 65 20 70 61 72 73 65 oot, since parse
0a00: 45 78 70 72 65 73 73 69 6f 6e 73 20 69 73 20 63 Expressions is c
0a10: 61 6c 6c 65 64 20 77 68 69 6c 65 20 77 65 27 72 alled while we'r
0a20: 65 20 6d 6f 75 6e 74 69 6e 67 20 74 68 61 74 20 e mounting that
0a30: 72 6f 6f 74 0a 20 20 20 20 74 61 67 49 6d 70 6c root. tagImpl
0a40: 20 3d 20 67 65 74 54 61 67 28 64 6f 6d 29 0a 0a = getTag(dom)..
0a50: 20 20 20 20 69 66 28 69 73 56 69 72 74 75 61 6c if(isVirtual
0a60: 29 20 7b 0a 20 20 20 20 20 20 69 66 28 67 65 74 ) {. if(get
0a70: 41 74 74 72 69 62 75 74 65 28 64 6f 6d 2c 20 27 Attribute(dom, '
0a80: 76 69 72 74 75 61 6c 69 7a 65 64 27 29 29 20 7b virtualized')) {
0a90: 64 6f 6d 2e 70 61 72 65 6e 74 45 6c 65 6d 65 6e dom.parentElemen
0aa0: 74 2e 72 65 6d 6f 76 65 43 68 69 6c 64 28 64 6f t.removeChild(do
0ab0: 6d 29 20 7d 20 2f 2f 20 74 61 67 20 63 72 65 61 m) } // tag crea
0ac0: 74 65 64 2c 20 72 65 6d 6f 76 65 20 66 72 6f 6d ted, remove from
0ad0: 20 64 6f 6d 0a 20 20 20 20 20 20 69 66 28 21 74 dom. if(!t
0ae0: 61 67 49 6d 70 6c 20 26 26 20 21 67 65 74 41 74 agImpl && !getAt
0af0: 74 72 69 62 75 74 65 28 64 6f 6d 2c 20 27 76 69 tribute(dom, 'vi
0b00: 72 74 75 61 6c 69 7a 65 64 27 29 20 26 26 20 21 rtualized') && !
0b10: 67 65 74 41 74 74 72 69 62 75 74 65 28 64 6f 6d getAttribute(dom
0b20: 2c 20 27 6c 6f 6f 70 56 69 72 74 75 61 6c 27 29 , 'loopVirtual')
0b30: 29 20 20 2f 2f 20 6f 6b 20 74 6f 20 63 72 65 61 ) // ok to crea
0b40: 74 65 20 76 69 72 74 75 61 6c 20 74 61 67 0a 20 te virtual tag.
0b50: 20 20 20 20 20 20 20 74 61 67 49 6d 70 6c 20 3d tagImpl =
0b60: 20 7b 20 74 6d 70 6c 3a 20 64 6f 6d 2e 6f 75 74 { tmpl: dom.out
0b70: 65 72 48 54 4d 4c 20 7d 0a 20 20 20 20 7d 0a 0a erHTML }. }..
0b80: 20 20 20 20 69 66 20 28 74 61 67 49 6d 70 6c 20 if (tagImpl
0b90: 26 26 20 28 64 6f 6d 20 21 3d 3d 20 72 6f 6f 74 && (dom !== root
0ba0: 20 7c 7c 20 6d 75 73 74 49 6e 63 6c 75 64 65 52 || mustIncludeR
0bb0: 6f 6f 74 29 29 20 7b 0a 20 20 20 20 20 20 63 6f oot)) {. co
0bc0: 6e 73 74 20 68 61 73 49 73 44 69 72 65 63 74 69 nst hasIsDirecti
0bd0: 76 65 20 3d 20 67 65 74 41 74 74 72 69 62 75 74 ve = getAttribut
0be0: 65 28 64 6f 6d 2c 20 49 53 5f 44 49 52 45 43 54 e(dom, IS_DIRECT
0bf0: 49 56 45 29 0a 20 20 20 20 20 20 69 66 28 69 73 IVE). if(is
0c00: 56 69 72 74 75 61 6c 20 26 26 20 21 68 61 73 49 Virtual && !hasI
0c10: 73 44 69 72 65 63 74 69 76 65 29 20 7b 20 2f 2f sDirective) { //
0c20: 20 68 61 6e 64 6c 65 64 20 69 6e 20 75 70 64 61 handled in upda
0c30: 74 65 0a 20 20 20 20 20 20 20 20 2f 2f 20 63 61 te. // ca
0c40: 6e 20 6e 6f 74 20 72 65 6d 6f 76 65 20 61 74 74 n not remove att
0c50: 72 69 62 75 74 65 20 6c 69 6b 65 20 64 69 72 65 ribute like dire
0c60: 63 74 69 76 65 73 0a 20 20 20 20 20 20 20 20 2f ctives. /
0c70: 2f 20 73 6f 20 66 6c 61 67 20 66 6f 72 20 72 65 / so flag for re
0c80: 6d 6f 76 61 6c 20 61 66 74 65 72 20 63 72 65 61 moval after crea
0c90: 74 69 6f 6e 20 74 6f 20 70 72 65 76 65 6e 74 20 tion to prevent
0ca0: 6d 61 78 69 6d 75 6d 20 73 74 61 63 6b 20 65 72 maximum stack er
0cb0: 72 6f 72 0a 20 20 20 20 20 20 20 20 73 65 74 41 ror. setA
0cc0: 74 74 72 69 62 75 74 65 28 64 6f 6d 2c 20 27 76 ttribute(dom, 'v
0cd0: 69 72 74 75 61 6c 69 7a 65 64 27 2c 20 74 72 75 irtualized', tru
0ce0: 65 29 0a 20 20 20 20 20 20 20 20 63 6f 6e 73 74 e). const
0cf0: 20 74 61 67 20 3d 20 63 72 65 61 74 65 54 61 67 tag = createTag
0d00: 28 0a 20 20 20 20 20 20 20 20 20 20 7b 74 6d 70 (. {tmp
0d10: 6c 3a 20 64 6f 6d 2e 6f 75 74 65 72 48 54 4d 4c l: dom.outerHTML
0d20: 7d 2c 0a 20 20 20 20 20 20 20 20 20 20 7b 72 6f },. {ro
0d30: 6f 74 3a 20 64 6f 6d 2c 20 70 61 72 65 6e 74 3a ot: dom, parent:
0d40: 20 74 68 69 73 7d 2c 0a 20 20 20 20 20 20 20 20 this},.
0d50: 20 20 64 6f 6d 2e 69 6e 6e 65 72 48 54 4d 4c 0a dom.innerHTML.
0d60: 20 20 20 20 20 20 20 20 29 0a 0a 20 20 20 20 20 )..
0d70: 20 20 20 65 78 70 72 65 73 73 69 6f 6e 73 2e 70 expressions.p
0d80: 75 73 68 28 74 61 67 29 20 2f 2f 20 6e 6f 20 72 ush(tag) // no r
0d90: 65 74 75 72 6e 2c 20 61 6e 6f 6e 79 6d 6f 75 73 eturn, anonymous
0da0: 20 74 61 67 2c 20 6b 65 65 70 20 70 61 72 73 69 tag, keep parsi
0db0: 6e 67 0a 20 20 20 20 20 20 7d 20 65 6c 73 65 20 ng. } else
0dc0: 7b 0a 20 20 20 20 20 20 20 20 69 66 20 28 68 61 {. if (ha
0dd0: 73 49 73 44 69 72 65 63 74 69 76 65 20 26 26 20 sIsDirective &&
0de0: 69 73 56 69 72 74 75 61 6c 29 0a 20 20 20 20 20 isVirtual).
0df0: 20 20 20 20 20 77 61 72 6e 28 60 56 69 72 74 75 warn(`Virtu
0e00: 61 6c 20 74 61 67 73 20 73 68 6f 75 6c 64 6e 27 al tags shouldn'
0e10: 74 20 62 65 20 75 73 65 64 20 74 6f 67 65 74 68 t be used togeth
0e20: 65 72 20 77 69 74 68 20 74 68 65 20 22 24 7b 49 er with the "${I
0e30: 53 5f 44 49 52 45 43 54 49 56 45 7d 22 20 61 74 S_DIRECTIVE}" at
0e40: 74 72 69 62 75 74 65 20 2d 20 68 74 74 70 73 3a tribute - https:
0e50: 2f 2f 67 69 74 68 75 62 2e 63 6f 6d 2f 72 69 6f //github.com/rio
0e60: 74 2f 72 69 6f 74 2f 69 73 73 75 65 73 2f 32 35 t/riot/issues/25
0e70: 31 31 60 29 0a 0a 20 20 20 20 20 20 20 20 65 78 11`).. ex
0e80: 70 72 65 73 73 69 6f 6e 73 2e 70 75 73 68 28 0a pressions.push(.
0e90: 20 20 20 20 20 20 20 20 20 20 69 6e 69 74 43 68 initCh
0ea0: 69 6c 64 28 0a 20 20 20 20 20 20 20 20 20 20 20 ild(.
0eb0: 20 74 61 67 49 6d 70 6c 2c 0a 20 20 20 20 20 20 tagImpl,.
0ec0: 20 20 20 20 20 20 7b 0a 20 20 20 20 20 20 20 20 {.
0ed0: 20 20 20 20 20 20 72 6f 6f 74 3a 20 64 6f 6d 2c root: dom,
0ee0: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 70 . p
0ef0: 61 72 65 6e 74 3a 20 74 68 69 73 0a 20 20 20 20 arent: this.
0f00: 20 20 20 20 20 20 20 20 7d 2c 0a 20 20 20 20 20 },.
0f10: 20 20 20 20 20 20 20 64 6f 6d 2e 69 6e 6e 65 72 dom.inner
0f20: 48 54 4d 4c 2c 0a 20 20 20 20 20 20 20 20 20 20 HTML,.
0f30: 20 20 74 68 69 73 0a 20 20 20 20 20 20 20 20 20 this.
0f40: 20 29 0a 20 20 20 20 20 20 20 20 29 0a 20 20 20 ). ).
0f50: 20 20 20 20 20 72 65 74 75 72 6e 20 66 61 6c 73 return fals
0f60: 65 0a 20 20 20 20 20 20 7d 0a 20 20 20 20 7d 0a e. }. }.
0f70: 0a 20 20 20 20 2f 2f 20 61 74 74 72 69 62 75 74 . // attribut
0f80: 65 20 65 78 70 72 65 73 73 69 6f 6e 73 0a 20 20 e expressions.
0f90: 20 20 70 61 72 73 65 41 74 74 72 69 62 75 74 65 parseAttribute
0fa0: 73 2e 61 70 70 6c 79 28 74 68 69 73 2c 20 5b 64 s.apply(this, [d
0fb0: 6f 6d 2c 20 64 6f 6d 2e 61 74 74 72 69 62 75 74 om, dom.attribut
0fc0: 65 73 2c 20 28 61 74 74 72 2c 20 65 78 70 72 29 es, (attr, expr)
0fd0: 20 3d 3e 20 7b 0a 20 20 20 20 20 20 69 66 20 28 => {. if (
0fe0: 21 65 78 70 72 29 20 72 65 74 75 72 6e 0a 20 20 !expr) return.
0ff0: 20 20 20 20 65 78 70 72 65 73 73 69 6f 6e 73 2e expressions.
1000: 70 75 73 68 28 65 78 70 72 29 0a 20 20 20 20 7d push(expr). }
1010: 5d 29 0a 20 20 7d 29 0a 0a 20 20 72 65 74 75 72 ]). }).. retur
1020: 6e 20 65 78 70 72 65 73 73 69 6f 6e 73 0a 7d 0a n expressions.}.
1030: 0a 2f 2a 2a 0a 20 2a 20 43 61 6c 6c 73 20 60 66 ./**. * Calls `f
1040: 6e 60 20 66 6f 72 20 65 76 65 72 79 20 61 74 74 n` for every att
1050: 72 69 62 75 74 65 20 6f 6e 20 61 6e 20 65 6c 65 ribute on an ele
1060: 6d 65 6e 74 2e 20 49 66 20 74 68 61 74 20 61 74 ment. If that at
1070: 74 72 20 68 61 73 20 61 6e 20 65 78 70 72 65 73 tr has an expres
1080: 73 69 6f 6e 2c 0a 20 2a 20 69 74 20 69 73 20 61 sion,. * it is a
1090: 6c 73 6f 20 70 61 73 73 65 64 20 74 6f 20 66 6e lso passed to fn
10a0: 2e 0a 20 2a 20 40 74 68 69 73 20 54 61 67 0a 20 .. * @this Tag.
10b0: 2a 20 40 70 61 72 61 6d 20 20 20 7b 20 48 54 4d * @param { HTM
10c0: 4c 45 6c 65 6d 65 6e 74 20 7d 20 64 6f 6d 20 2d LElement } dom -
10d0: 20 64 6f 6d 20 6e 6f 64 65 20 74 6f 20 70 61 72 dom node to par
10e0: 73 65 0a 20 2a 20 40 70 61 72 61 6d 20 20 20 7b se. * @param {
10f0: 20 41 72 72 61 79 20 7d 20 61 74 74 72 73 20 2d Array } attrs -
1100: 20 61 72 72 61 79 20 6f 66 20 61 74 74 72 69 62 array of attrib
1110: 75 74 65 73 0a 20 2a 20 40 70 61 72 61 6d 20 20 utes. * @param
1120: 20 7b 20 46 75 6e 63 74 69 6f 6e 20 7d 20 66 6e { Function } fn
1130: 20 2d 20 63 61 6c 6c 62 61 63 6b 20 74 6f 20 65 - callback to e
1140: 78 65 63 20 6f 6e 20 61 6e 79 20 69 74 65 72 61 xec on any itera
1150: 74 69 6f 6e 0a 20 2a 2f 0a 65 78 70 6f 72 74 20 tion. */.export
1160: 66 75 6e 63 74 69 6f 6e 20 70 61 72 73 65 41 74 function parseAt
1170: 74 72 69 62 75 74 65 73 28 64 6f 6d 2c 20 61 74 tributes(dom, at
1180: 74 72 73 2c 20 66 6e 29 20 7b 0a 20 20 65 61 63 trs, fn) {. eac
1190: 68 28 61 74 74 72 73 2c 20 28 61 74 74 72 29 20 h(attrs, (attr)
11a0: 3d 3e 20 7b 0a 20 20 20 20 69 66 20 28 21 61 74 => {. if (!at
11b0: 74 72 29 20 72 65 74 75 72 6e 20 66 61 6c 73 65 tr) return false
11c0: 0a 0a 20 20 20 20 63 6f 6e 73 74 20 6e 61 6d 65 .. const name
11d0: 20 3d 20 61 74 74 72 2e 6e 61 6d 65 0a 20 20 20 = attr.name.
11e0: 20 63 6f 6e 73 74 20 62 6f 6f 6c 20 3d 20 69 73 const bool = is
11f0: 42 6f 6f 6c 41 74 74 72 28 6e 61 6d 65 29 0a 20 BoolAttr(name).
1200: 20 20 20 6c 65 74 20 65 78 70 72 0a 0a 20 20 20 let expr..
1210: 20 69 66 20 28 63 6f 6e 74 61 69 6e 73 28 52 45 if (contains(RE
1220: 46 5f 44 49 52 45 43 54 49 56 45 53 2c 20 6e 61 F_DIRECTIVES, na
1230: 6d 65 29 20 26 26 20 64 6f 6d 2e 74 61 67 4e 61 me) && dom.tagNa
1240: 6d 65 2e 74 6f 4c 6f 77 65 72 43 61 73 65 28 29 me.toLowerCase()
1250: 20 21 3d 3d 20 59 49 45 4c 44 5f 54 41 47 29 20 !== YIELD_TAG)
1260: 7b 0a 20 20 20 20 20 20 65 78 70 72 20 3d 20 20 {. expr =
1270: 63 72 65 61 74 65 52 65 66 44 69 72 65 63 74 69 createRefDirecti
1280: 76 65 28 64 6f 6d 2c 20 74 68 69 73 2c 20 6e 61 ve(dom, this, na
1290: 6d 65 2c 20 61 74 74 72 2e 76 61 6c 75 65 29 0a me, attr.value).
12a0: 20 20 20 20 7d 20 65 6c 73 65 20 69 66 20 28 74 } else if (t
12b0: 6d 70 6c 2e 68 61 73 45 78 70 72 28 61 74 74 72 mpl.hasExpr(attr
12c0: 2e 76 61 6c 75 65 29 29 20 7b 0a 20 20 20 20 20 .value)) {.
12d0: 20 65 78 70 72 20 3d 20 7b 64 6f 6d 2c 20 65 78 expr = {dom, ex
12e0: 70 72 3a 20 61 74 74 72 2e 76 61 6c 75 65 2c 20 pr: attr.value,
12f0: 61 74 74 72 3a 20 6e 61 6d 65 2c 20 62 6f 6f 6c attr: name, bool
1300: 7d 0a 20 20 20 20 7d 0a 0a 20 20 20 20 66 6e 28 }. }.. fn(
1310: 61 74 74 72 2c 20 65 78 70 72 29 0a 20 20 7d 29 attr, expr). })
1320: 0a 7d 0a .}.