0000: 69 6d 70 6f 72 74 20 7b 0a 20 20 69 6e 6a 65 63 import {. injec
0010: 74 48 54 4d 4c 2c 0a 20 20 24 2c 0a 20 20 6e 6f tHTML,. $,. no
0020: 72 6d 61 6c 69 7a 65 48 54 4d 4c 2c 0a 20 20 66 rmalizeHTML,. f
0030: 69 72 65 45 76 65 6e 74 0a 7d 20 66 72 6f 6d 20 ireEvent.} from
0040: 27 2e 2e 2f 2e 2e 2f 2e 2e 2f 68 65 6c 70 65 72 '../../../helper
0050: 73 2f 69 6e 64 65 78 27 0a 0a 0a 2f 2f 20 69 6e s/index'...// in
0060: 63 6c 75 64 65 20 73 70 65 63 69 61 6c 20 74 61 clude special ta
0070: 67 73 20 74 6f 20 74 65 73 74 20 73 70 65 63 69 gs to test speci
0080: 66 69 63 20 66 65 61 74 75 72 65 73 0a 69 6d 70 fic features.imp
0090: 6f 72 74 20 27 2e 2e 2f 2e 2e 2f 2e 2e 2f 74 61 ort '../../../ta
00a0: 67 2f 69 6e 6e 65 72 2d 68 74 6d 6c 2e 74 61 67 g/inner-html.tag
00b0: 27 0a 69 6d 70 6f 72 74 20 27 2e 2e 2f 2e 2e 2f '.import '../../
00c0: 2e 2e 2f 74 61 67 2f 79 69 65 6c 64 2d 6e 6f 2d ../tag/yield-no-
00d0: 73 6c 61 73 68 2e 74 61 67 27 0a 69 6d 70 6f 72 slash.tag'.impor
00e0: 74 20 27 2e 2e 2f 2e 2e 2f 2e 2e 2f 74 61 67 2f t '../../../tag/
00f0: 79 69 65 6c 64 2d 6d 75 6c 74 69 2e 74 61 67 27 yield-multi.tag'
0100: 0a 69 6d 70 6f 72 74 20 27 2e 2e 2f 2e 2e 2f 2e .import '../../.
0110: 2e 2f 74 61 67 2f 79 69 65 6c 64 2d 6d 75 6c 74 ./tag/yield-mult
0120: 69 32 2e 74 61 67 27 0a 69 6d 70 6f 72 74 20 27 i2.tag'.import '
0130: 2e 2e 2f 2e 2e 2f 2e 2e 2f 74 61 67 2f 79 69 65 ../../../tag/yie
0140: 6c 64 2d 66 72 6f 6d 2d 64 65 66 61 75 6c 74 2e ld-from-default.
0150: 74 61 67 27 0a 69 6d 70 6f 72 74 20 27 2e 2e 2f tag'.import '../
0160: 2e 2e 2f 2e 2e 2f 74 61 67 2f 79 69 65 6c 64 2d ../../tag/yield-
0170: 6e 65 73 74 65 64 2e 74 61 67 27 0a 0a 0a 64 65 nested.tag'...de
0180: 73 63 72 69 62 65 28 27 52 69 6f 74 20 74 72 61 scribe('Riot tra
0190: 6e 73 63 6c 75 73 69 6f 6e 27 2c 20 66 75 6e 63 nsclusion', func
01a0: 74 69 6f 6e 28 29 20 7b 0a 0a 20 20 62 65 66 6f tion() {.. befo
01b0: 72 65 45 61 63 68 28 66 75 6e 63 74 69 6f 6e 28 reEach(function(
01c0: 29 20 7b 0a 20 20 20 20 2f 2f 20 74 61 67 20 75 ) {. // tag u
01d0: 73 65 64 20 69 6e 20 6d 75 6c 74 69 70 6c 65 20 sed in multiple
01e0: 74 65 73 74 73 0a 20 20 20 20 72 69 6f 74 2e 74 tests. riot.t
01f0: 61 67 28 27 69 6e 6e 65 72 27 2c 20 27 3c 70 3e ag('inner', '<p>
0200: 7b 6f 70 74 73 2e 76 61 6c 75 65 7d 3c 2f 70 3e {opts.value}</p>
0210: 27 29 0a 20 20 7d 29 0a 0a 20 20 69 74 28 27 73 '). }).. it('s
0220: 69 6d 70 6c 65 20 68 74 6d 6c 20 74 72 61 6e 73 imple html trans
0230: 63 6c 75 73 69 6f 6e 20 76 69 61 20 3c 79 69 65 clusion via <yie
0240: 6c 64 3e 20 74 61 67 27 2c 20 66 75 6e 63 74 69 ld> tag', functi
0250: 6f 6e 28 29 20 7b 0a 0a 20 20 20 20 69 6e 6a 65 on() {.. inje
0260: 63 74 48 54 4d 4c 28 5b 0a 20 20 20 20 20 20 27 ctHTML([. '
0270: 3c 69 6e 6e 65 72 2d 68 74 6d 6c 3e 27 2c 0a 20 <inner-html>',.
0280: 20 20 20 20 20 27 20 20 7b 20 67 72 65 65 74 69 ' { greeti
0290: 6e 67 20 7d 27 2c 0a 20 20 20 20 20 20 27 20 20 ng }',. '
02a0: 3c 69 6e 6e 65 72 20 76 61 6c 75 65 3d 22 63 69 <inner value="ci
02b0: 61 6f 20 6d 6f 6e 64 6f 22 3e 3c 2f 69 6e 6e 65 ao mondo"></inne
02c0: 72 3e 27 2c 0a 20 20 20 20 20 20 27 3c 2f 69 6e r>',. '</in
02d0: 6e 65 72 2d 68 74 6d 6c 3e 27 0a 20 20 20 20 5d ner-html>'. ]
02e0: 29 0a 0a 20 20 20 20 76 61 72 20 74 61 67 20 3d ).. var tag =
02f0: 20 72 69 6f 74 2e 6d 6f 75 6e 74 28 27 69 6e 6e riot.mount('inn
0300: 65 72 2d 68 74 6d 6c 27 29 5b 30 5d 0a 0a 20 20 er-html')[0]..
0310: 20 20 65 78 70 65 63 74 28 6e 6f 72 6d 61 6c 69 expect(normali
0320: 7a 65 48 54 4d 4c 28 74 61 67 2e 72 6f 6f 74 2e zeHTML(tag.root.
0330: 69 6e 6e 65 72 48 54 4d 4c 29 29 2e 74 6f 2e 62 innerHTML)).to.b
0340: 65 2e 65 71 75 61 6c 28 27 3c 68 31 3e 48 65 6c e.equal('<h1>Hel
0350: 6c 6f 2c 20 57 6f 72 6c 64 20 20 3c 69 6e 6e 65 lo, World <inne
0360: 72 20 76 61 6c 75 65 3d 22 63 69 61 6f 20 6d 6f r value="ciao mo
0370: 6e 64 6f 22 3e 3c 70 3e 63 69 61 6f 20 6d 6f 6e ndo"><p>ciao mon
0380: 64 6f 3c 2f 70 3e 3c 2f 69 6e 6e 65 72 3e 3c 2f do</p></inner></
0390: 68 31 3e 27 29 0a 0a 20 20 20 20 74 61 67 2e 75 h1>').. tag.u
03a0: 6e 6d 6f 75 6e 74 28 29 0a 0a 20 20 7d 29 0a 0a nmount().. })..
03b0: 20 20 69 74 28 27 79 69 65 6c 64 20 77 69 74 68 it('yield with
03c0: 6f 75 74 20 63 6c 6f 73 69 6e 67 20 73 6c 61 73 out closing slas
03d0: 68 20 73 68 6f 75 6c 64 20 62 65 20 77 6f 72 6b h should be work
03e0: 20 61 73 20 65 78 70 65 63 74 65 64 27 2c 20 66 as expected', f
03f0: 75 6e 63 74 69 6f 6e 28 29 20 7b 0a 0a 20 20 20 unction() {..
0400: 20 69 6e 6a 65 63 74 48 54 4d 4c 28 5b 0a 20 20 injectHTML([.
0410: 20 20 20 20 27 3c 79 69 65 6c 64 2d 6e 6f 2d 73 '<yield-no-s
0420: 6c 61 73 68 3e 27 2c 0a 20 20 20 20 20 20 27 20 lash>',. '
0430: 20 66 6f 6f 27 2c 0a 20 20 20 20 20 20 27 3c 2f foo',. '</
0440: 79 69 65 6c 64 2d 6e 6f 2d 73 6c 61 73 68 3e 27 yield-no-slash>'
0450: 0a 20 20 20 20 5d 29 0a 0a 20 20 20 20 76 61 72 . ]).. var
0460: 20 74 61 67 20 3d 20 72 69 6f 74 2e 6d 6f 75 6e tag = riot.moun
0470: 74 28 27 79 69 65 6c 64 2d 6e 6f 2d 73 6c 61 73 t('yield-no-slas
0480: 68 27 29 5b 30 5d 0a 0a 20 20 20 20 65 78 70 65 h')[0].. expe
0490: 63 74 28 6e 6f 72 6d 61 6c 69 7a 65 48 54 4d 4c ct(normalizeHTML
04a0: 28 74 61 67 2e 72 6f 6f 74 2e 69 6e 6e 65 72 48 (tag.root.innerH
04b0: 54 4d 4c 29 29 2e 74 6f 2e 62 65 2e 65 71 75 61 TML)).to.be.equa
04c0: 6c 28 27 66 6f 6f 27 29 0a 20 20 20 20 74 61 67 l('foo'). tag
04d0: 2e 75 6e 6d 6f 75 6e 74 28 29 0a 0a 20 20 7d 29 .unmount().. })
04e0: 0a 0a 20 20 69 74 28 27 3c 79 69 65 6c 64 3e 20 .. it('<yield>
04f0: 66 72 6f 6d 2f 74 6f 20 6d 75 6c 74 69 2d 74 72 from/to multi-tr
0500: 61 6e 73 63 6c 75 73 69 6f 6e 27 2c 20 66 75 6e ansclusion', fun
0510: 63 74 69 6f 6e 28 29 20 7b 0a 20 20 20 20 69 6e ction() {. in
0520: 6a 65 63 74 48 54 4d 4c 28 27 3c 79 69 65 6c 64 jectHTML('<yield
0530: 2d 6d 75 6c 74 69 3e 3c 79 69 65 6c 64 20 74 6f -multi><yield to
0540: 3d 22 63 6f 6e 74 65 6e 74 22 3e 63 6f 6e 74 65 ="content">conte
0550: 6e 74 3c 2f 79 69 65 6c 64 3e 3c 79 69 65 6c 64 nt</yield><yield
0560: 20 74 6f 3d 22 6e 65 73 74 65 64 2d 63 6f 6e 74 to="nested-cont
0570: 65 6e 74 22 3e 63 6f 6e 74 65 6e 74 3c 2f 79 69 ent">content</yi
0580: 65 6c 64 3e 3c 79 69 65 6c 64 20 74 6f 3d 22 6e eld><yield to="n
0590: 6f 77 68 65 72 65 22 3e 63 6f 6e 74 65 6e 74 3c owhere">content<
05a0: 2f 79 69 65 6c 64 3e 3c 2f 79 69 65 6c 64 2d 6d /yield></yield-m
05b0: 75 6c 74 69 3e 27 29 0a 20 20 20 20 76 61 72 20 ulti>'). var
05c0: 74 61 67 20 3d 20 72 69 6f 74 2e 6d 6f 75 6e 74 tag = riot.mount
05d0: 28 27 79 69 65 6c 64 2d 6d 75 6c 74 69 27 2c 20 ('yield-multi',
05e0: 7b 7d 29 5b 30 5d 0a 20 20 20 20 65 78 70 65 63 {})[0]. expec
05f0: 74 28 6e 6f 72 6d 61 6c 69 7a 65 48 54 4d 4c 28 t(normalizeHTML(
0600: 74 61 67 2e 72 6f 6f 74 2e 69 6e 6e 65 72 48 54 tag.root.innerHT
0610: 4d 4c 29 29 2e 74 6f 2e 62 65 2e 65 71 75 61 6c ML)).to.be.equal
0620: 28 27 3c 70 3e 79 69 65 6c 64 20 74 68 65 20 63 ('<p>yield the c
0630: 6f 6e 74 65 6e 74 20 68 65 72 65 3c 2f 70 3e 3c ontent here</p><
0640: 64 69 76 3e 3c 70 3e 79 69 65 6c 64 20 74 68 65 div><p>yield the
0650: 20 6e 65 73 74 65 64 20 63 6f 6e 74 65 6e 74 20 nested content
0660: 68 65 72 65 3c 2f 70 3e 3c 70 3e 64 6f 20 6e 6f here</p><p>do no
0670: 74 20 79 69 65 6c 64 20 74 68 65 20 75 6e 72 65 t yield the unre
0680: 66 65 72 65 6e 63 65 20 63 6f 6e 74 65 6e 74 20 ference content
0690: 68 65 72 65 3c 2f 70 3e 3c 2f 64 69 76 3e 27 29 here</p></div>')
06a0: 0a 20 20 20 20 74 61 67 2e 75 6e 6d 6f 75 6e 74 . tag.unmount
06b0: 28 29 0a 20 20 7d 29 0a 0a 20 20 69 74 28 27 3c (). }).. it('<
06c0: 79 69 65 6c 64 3e 20 66 72 6f 6d 2f 74 6f 20 6d yield> from/to m
06d0: 75 6c 74 69 2d 74 72 61 6e 73 63 6c 75 73 69 6f ulti-transclusio
06e0: 6e 20 6e 65 73 74 65 64 20 23 31 34 35 38 27 2c n nested #1458',
06f0: 20 66 75 6e 63 74 69 6f 6e 28 29 20 7b 0a 20 20 function() {.
0700: 20 20 76 61 72 20 68 74 6d 6c 20 3d 20 5b 0a 20 var html = [.
0710: 20 20 20 20 20 27 3c 79 69 65 6c 64 2d 6d 75 6c '<yield-mul
0720: 74 69 32 3e 27 2c 0a 20 20 20 20 20 20 27 20 20 ti2>',. '
0730: 3c 79 69 65 6c 64 20 74 6f 3d 22 6f 70 74 69 6f <yield to="optio
0740: 6e 73 22 3e 27 2c 0a 20 20 20 20 20 20 27 20 20 ns">',. '
0750: 20 20 3c 75 6c 3e 27 2c 0a 20 20 20 20 20 20 27 <ul>',. '
0760: 20 20 20 20 20 20 3c 6c 69 3e 4f 70 74 69 6f 6e <li>Option
0770: 20 31 3c 2f 6c 69 3e 27 2c 0a 20 20 20 20 20 20 1</li>',.
0780: 27 20 20 20 20 20 20 3c 6c 69 3e 4f 70 74 69 6f ' <li>Optio
0790: 6e 20 32 3c 2f 6c 69 3e 27 2c 0a 20 20 20 20 20 n 2</li>',.
07a0: 20 27 20 20 20 20 3c 2f 75 6c 3e 27 2c 0a 20 20 ' </ul>',.
07b0: 20 20 20 20 27 20 20 3c 2f 79 69 65 6c 64 3e 27 ' </yield>'
07c0: 2c 0a 20 20 20 20 20 20 27 20 20 3c 64 69 76 3e ,. ' <div>
07d0: 27 2c 0a 20 20 20 20 20 20 27 20 20 20 20 3c 79 ',. ' <y
07e0: 69 65 6c 64 20 74 6f 3d 22 74 6f 67 67 6c 65 22 ield to="toggle"
07f0: 3e 3c 73 70 61 6e 20 63 6c 61 73 73 3d 22 69 63 ><span class="ic
0800: 6f 6e 22 3e 3c 2f 73 70 61 6e 3e 3c 2f 79 69 65 on"></span></yie
0810: 6c 64 3e 27 2c 0a 20 20 20 20 20 20 27 20 20 20 ld>',. '
0820: 20 3c 79 69 65 6c 64 20 74 6f 3d 22 68 65 6c 6c <yield to="hell
0830: 6f 22 3e 48 65 6c 6c 6f 3c 2f 79 69 65 6c 64 3e o">Hello</yield>
0840: 3c 79 69 65 6c 64 20 74 6f 3d 22 77 6f 72 6c 64 <yield to="world
0850: 22 3e 57 6f 72 6c 64 3c 2f 79 69 65 6c 64 3e 27 ">World</yield>'
0860: 2c 0a 20 20 20 20 20 20 27 20 20 20 20 3c 79 69 ,. ' <yi
0870: 65 6c 64 20 74 6f 3d 22 68 65 6c 6c 6f 22 3e 64 eld to="hello">d
0880: 75 6d 6d 79 3c 2f 79 69 65 6c 64 3e 27 2c 0a 20 ummy</yield>',.
0890: 20 20 20 20 20 27 20 20 3c 2f 64 69 76 3e 27 2c ' </div>',
08a0: 0a 20 20 20 20 20 20 27 3c 2f 79 69 65 6c 64 2d . '</yield-
08b0: 6d 75 6c 74 69 32 3e 27 0a 20 20 20 20 5d 0a 20 multi2>'. ].
08c0: 20 20 20 69 6e 6a 65 63 74 48 54 4d 4c 28 68 74 injectHTML(ht
08d0: 6d 6c 2e 6a 6f 69 6e 28 27 5c 6e 27 29 29 0a 20 ml.join('\n')).
08e0: 20 20 20 65 78 70 65 63 74 28 24 28 27 79 69 65 expect($('yie
08f0: 6c 64 2d 6d 75 6c 74 69 32 27 29 29 2e 6e 6f 74 ld-multi2')).not
0900: 2e 74 6f 2e 62 65 2e 65 71 75 61 6c 28 6e 75 6c .to.be.equal(nul
0910: 6c 29 0a 20 20 20 20 76 61 72 20 74 61 67 20 3d l). var tag =
0920: 20 72 69 6f 74 2e 6d 6f 75 6e 74 28 27 79 69 65 riot.mount('yie
0930: 6c 64 2d 6d 75 6c 74 69 32 27 2c 20 7b 7d 29 5b ld-multi2', {})[
0940: 30 5d 0a 20 20 20 20 68 74 6d 6c 20 3d 20 27 3c 0]. html = '<
0950: 75 6c 3e 3c 6c 69 3e 4f 70 74 69 6f 6e 20 31 3c ul><li>Option 1<
0960: 2f 6c 69 3e 3c 6c 69 3e 4f 70 74 69 6f 6e 20 32 /li><li>Option 2
0970: 3c 2f 6c 69 3e 3c 2f 75 6c 3e 3c 73 70 61 6e 20 </li></ul><span
0980: 63 6c 61 73 73 3d 22 69 63 6f 6e 22 3e 3c 2f 73 class="icon"></s
0990: 70 61 6e 3e 3c 70 3e 48 65 6c 6c 6f 20 57 6f 72 pan><p>Hello Wor
09a0: 6c 64 3c 2f 70 3e 27 0a 20 20 20 20 65 78 70 65 ld</p>'. expe
09b0: 63 74 28 6e 6f 72 6d 61 6c 69 7a 65 48 54 4d 4c ct(normalizeHTML
09c0: 28 74 61 67 2e 72 6f 6f 74 2e 69 6e 6e 65 72 48 (tag.root.innerH
09d0: 54 4d 4c 29 29 2e 74 6f 2e 62 65 2e 65 71 75 61 TML)).to.be.equa
09e0: 6c 28 68 74 6d 6c 29 0a 20 20 20 20 74 61 67 2e l(html). tag.
09f0: 75 6e 6d 6f 75 6e 74 28 29 0a 20 20 7d 29 0a 0a unmount(). })..
0a00: 0a 20 20 69 74 28 27 3c 79 69 65 6c 64 20 66 72 . it('<yield fr
0a10: 6f 6d 3e 20 6e 61 6d 65 20 63 61 6e 20 62 65 20 om> name can be
0a20: 75 6e 71 75 6f 74 65 64 2c 20 77 69 74 68 6f 75 unquoted, withou
0a30: 74 20 3c 79 69 65 6c 64 20 74 6f 3e 20 64 65 66 t <yield to> def
0a40: 61 75 6c 74 20 74 6f 20 69 74 73 20 63 6f 6e 74 ault to its cont
0a50: 65 6e 74 27 2c 20 66 75 6e 63 74 69 6f 6e 20 28 ent', function (
0a60: 29 20 7b 0a 20 20 20 20 76 61 72 20 68 74 6d 6c ) {. var html
0a70: 20 3d 20 5b 0a 20 20 20 20 20 20 27 3c 79 69 65 = [. '<yie
0a80: 6c 64 2d 66 72 6f 6d 2d 64 65 66 61 75 6c 74 3e ld-from-default>
0a90: 27 2c 0a 20 20 20 20 20 20 27 20 3c 79 69 65 6c ',. ' <yiel
0aa0: 64 20 74 6f 3d 22 69 63 6f 6e 22 3e 6d 79 2d 69 d to="icon">my-i
0ab0: 63 6f 6e 3c 2f 79 69 65 6c 64 3e 27 2c 0a 20 20 con</yield>',.
0ac0: 20 20 20 20 27 20 3c 79 69 65 6c 64 20 74 6f 3d ' <yield to=
0ad0: 22 68 65 6c 6c 6f 22 3e 48 65 6c 6c 6f 20 24 31 "hello">Hello $1
0ae0: 20 24 32 3c 2f 79 69 65 6c 64 3e 27 2c 0a 20 20 $2</yield>',.
0af0: 20 20 20 20 27 20 3c 79 69 65 6c 64 20 74 6f 3d ' <yield to=
0b00: 22 6c 6f 6f 70 22 3e 5b e2 81 97 66 6f 6f e2 81 "loop">[...foo..
0b10: 97 2c 5c 27 62 61 72 5c 27 5d 3c 2f 79 69 65 6c .,\'bar\']</yiel
0b20: 64 3e 27 2c 0a 20 20 20 20 20 20 27 3c 2f 79 69 d>',. '</yi
0b30: 65 6c 64 2d 66 72 6f 6d 2d 64 65 66 61 75 6c 74 eld-from-default
0b40: 3e 27 0a 20 20 20 20 5d 0a 0a 20 20 20 20 69 6e >'. ].. in
0b50: 6a 65 63 74 48 54 4d 4c 28 68 74 6d 6c 2e 6a 6f jectHTML(html.jo
0b60: 69 6e 28 27 5c 6e 27 29 29 0a 20 20 20 20 65 78 in('\n')). ex
0b70: 70 65 63 74 28 24 28 27 79 69 65 6c 64 2d 66 72 pect($('yield-fr
0b80: 6f 6d 2d 64 65 66 61 75 6c 74 27 29 29 2e 6e 6f om-default')).no
0b90: 74 2e 74 6f 2e 62 65 2e 65 71 75 61 6c 28 6e 75 t.to.be.equal(nu
0ba0: 6c 6c 29 0a 20 20 20 20 76 61 72 20 74 61 67 20 ll). var tag
0bb0: 3d 20 72 69 6f 74 2e 6d 6f 75 6e 74 28 27 79 69 = riot.mount('yi
0bc0: 65 6c 64 2d 66 72 6f 6d 2d 64 65 66 61 75 6c 74 eld-from-default
0bd0: 27 29 5b 30 5d 0a 20 20 20 20 68 74 6d 6c 20 3d ')[0]. html =
0be0: 20 27 3c 70 3e 28 6e 6f 20 6f 70 74 69 6f 6e 73 '<p>(no options
0bf0: 29 3c 2f 70 3e 3c 70 3e 48 65 6c 6c 6f 20 24 31 )</p><p>Hello $1
0c00: 20 24 32 20 3c 73 70 61 6e 20 63 6c 61 73 73 3d $2 <span class=
0c10: 22 6d 79 2d 69 63 6f 6e 22 3e 3c 2f 73 70 61 6e "my-icon"></span
0c20: 3e 3c 2f 70 3e 3c 70 3e 66 6f 6f 3c 2f 70 3e 3c ></p><p>foo</p><
0c30: 70 3e 62 61 72 3c 2f 70 3e 27 0a 20 20 20 20 65 p>bar</p>'. e
0c40: 78 70 65 63 74 28 6e 6f 72 6d 61 6c 69 7a 65 48 xpect(normalizeH
0c50: 54 4d 4c 28 74 61 67 2e 72 6f 6f 74 2e 69 6e 6e TML(tag.root.inn
0c60: 65 72 48 54 4d 4c 29 29 2e 74 6f 2e 62 65 2e 65 erHTML)).to.be.e
0c70: 71 75 61 6c 28 68 74 6d 6c 29 0a 20 20 20 20 74 qual(html). t
0c80: 61 67 2e 75 6e 6d 6f 75 6e 74 28 29 0a 20 20 7d ag.unmount(). }
0c90: 29 0a 0a 0a 20 20 69 74 28 27 6d 75 6c 74 69 70 )... it('multip
0ca0: 6c 65 20 6d 6f 75 6e 74 20 3c 79 69 65 6c 64 3e le mount <yield>
0cb0: 20 74 61 67 27 2c 20 66 75 6e 63 74 69 6f 6e 28 tag', function(
0cc0: 29 20 7b 0a 0a 20 20 20 20 69 6e 6a 65 63 74 48 ) {.. injectH
0cd0: 54 4d 4c 28 27 3c 69 6e 6e 65 72 2d 68 74 6d 6c TML('<inner-html
0ce0: 3e 57 6f 72 6c 64 20 20 3c 69 6e 6e 65 72 20 76 >World <inner v
0cf0: 61 6c 75 65 3d 22 63 69 61 6f 20 6d 6f 6e 64 6f alue="ciao mondo
0d00: 22 3e 3c 2f 69 6e 6e 65 72 3e 3c 2f 69 6e 6e 65 "></inner></inne
0d10: 72 2d 68 74 6d 6c 3e 27 29 0a 0a 20 20 20 20 72 r-html>').. r
0d20: 69 6f 74 2e 6d 6f 75 6e 74 28 27 69 6e 6e 65 72 iot.mount('inner
0d30: 2d 68 74 6d 6c 27 29 0a 20 20 20 20 72 69 6f 74 -html'). riot
0d40: 2e 6d 6f 75 6e 74 28 27 69 6e 6e 65 72 2d 68 74 .mount('inner-ht
0d50: 6d 6c 27 29 0a 20 20 20 20 72 69 6f 74 2e 6d 6f ml'). riot.mo
0d60: 75 6e 74 28 27 69 6e 6e 65 72 2d 68 74 6d 6c 27 unt('inner-html'
0d70: 29 0a 20 20 20 20 72 69 6f 74 2e 6d 6f 75 6e 74 ). riot.mount
0d80: 28 27 69 6e 6e 65 72 2d 68 74 6d 6c 27 29 0a 0a ('inner-html')..
0d90: 20 20 20 20 76 61 72 20 74 61 67 20 3d 20 72 69 var tag = ri
0da0: 6f 74 2e 6d 6f 75 6e 74 28 27 69 6e 6e 65 72 2d ot.mount('inner-
0db0: 68 74 6d 6c 27 29 5b 30 5d 0a 0a 20 20 20 20 65 html')[0].. e
0dc0: 78 70 65 63 74 28 6e 6f 72 6d 61 6c 69 7a 65 48 xpect(normalizeH
0dd0: 54 4d 4c 28 74 61 67 2e 72 6f 6f 74 2e 69 6e 6e TML(tag.root.inn
0de0: 65 72 48 54 4d 4c 29 29 2e 74 6f 2e 62 65 2e 65 erHTML)).to.be.e
0df0: 71 75 61 6c 28 27 3c 68 31 3e 48 65 6c 6c 6f 2c qual('<h1>Hello,
0e00: 20 57 6f 72 6c 64 20 20 3c 69 6e 6e 65 72 20 76 World <inner v
0e10: 61 6c 75 65 3d 22 63 69 61 6f 20 6d 6f 6e 64 6f alue="ciao mondo
0e20: 22 3e 3c 70 3e 63 69 61 6f 20 6d 6f 6e 64 6f 3c "><p>ciao mondo<
0e30: 2f 70 3e 3c 2f 69 6e 6e 65 72 3e 3c 2f 68 31 3e /p></inner></h1>
0e40: 27 29 0a 20 20 20 20 74 61 67 2e 75 6e 6d 6f 75 '). tag.unmou
0e50: 6e 74 28 29 0a 0a 20 20 7d 29 0a 0a 20 20 69 74 nt().. }).. it
0e60: 28 27 3c 79 69 65 6c 64 3e 20 63 6f 6e 74 65 6e ('<yield> conten
0e70: 74 73 20 69 6e 20 61 20 63 68 69 6c 64 20 67 65 ts in a child ge
0e80: 74 20 61 6c 77 61 79 73 20 63 6f 6d 70 69 6c 65 t always compile
0e90: 64 20 75 73 69 6e 67 20 69 74 73 20 70 61 72 65 d using its pare
0ea0: 6e 74 20 64 61 74 61 27 2c 20 66 75 6e 63 74 69 nt data', functi
0eb0: 6f 6e 28 64 6f 6e 65 29 20 7b 0a 0a 20 20 20 20 on(done) {..
0ec0: 69 6e 6a 65 63 74 48 54 4d 4c 28 27 3c 79 69 65 injectHTML('<yie
0ed0: 6c 64 2d 70 61 72 65 6e 74 3e 7b 20 67 72 65 65 ld-parent>{ gree
0ee0: 74 69 6e 67 20 7d 3c 2f 79 69 65 6c 64 2d 70 61 ting }</yield-pa
0ef0: 72 65 6e 74 3e 27 29 0a 0a 20 20 20 20 76 61 72 rent>').. var
0f00: 20 74 61 67 20 3d 20 72 69 6f 74 2e 6d 6f 75 6e tag = riot.moun
0f10: 74 28 27 79 69 65 6c 64 2d 70 61 72 65 6e 74 27 t('yield-parent'
0f20: 2c 20 7b 0a 20 20 20 20 20 20 73 61 79 53 6f 6d , {. saySom
0f30: 65 74 68 69 6e 67 3a 20 64 6f 6e 65 0a 20 20 20 ething: done.
0f40: 20 7d 29 5b 30 5d 0a 0a 20 20 20 20 65 78 70 65 })[0].. expe
0f50: 63 74 28 6e 6f 72 6d 61 6c 69 7a 65 48 54 4d 4c ct(normalizeHTML
0f60: 28 74 61 67 2e 72 6f 6f 74 2e 69 6e 6e 65 72 48 (tag.root.innerH
0f70: 54 4d 4c 29 29 2e 74 6f 2e 6d 61 74 63 68 28 2f TML)).to.match(/
0f80: 3c 68 31 3e 48 65 6c 6c 6f 2c 20 66 72 6f 6d 20 <h1>Hello, from
0f90: 74 68 65 20 70 61 72 65 6e 74 3c 5c 2f 68 31 3e the parent<\/h1>
0fa0: 3c 79 69 65 6c 64 2d 63 68 69 6c 64 3e 3c 68 31 <yield-child><h1
0fb0: 3e 47 72 65 65 74 69 6e 67 3c 5c 2f 68 31 3e 3c >Greeting<\/h1><
0fc0: 69 3e 66 72 6f 6d 20 74 68 65 20 63 68 69 6c 64 i>from the child
0fd0: 3c 5c 2f 69 3e 3c 64 69 76 28 2e 2b 7c 29 3e 3c <\/i><div(.+|)><
0fe0: 62 3e 77 6f 6f 68 61 3c 5c 2f 62 3e 3c 5c 2f 64 b>wooha<\/b><\/d
0ff0: 69 76 3e 3c 5c 2f 79 69 65 6c 64 2d 63 68 69 6c iv><\/yield-chil
1000: 64 3e 2f 29 0a 0a 20 20 20 20 74 61 67 2e 75 70 d>/).. tag.up
1010: 64 61 74 65 28 7b 0a 20 20 20 20 20 20 69 73 53 date({. isS
1020: 65 6c 65 63 74 65 64 3a 20 74 72 75 65 0a 20 20 elected: true.
1030: 20 20 7d 29 0a 0a 0a 20 20 20 20 65 78 70 65 63 })... expec
1040: 74 28 6e 6f 72 6d 61 6c 69 7a 65 48 54 4d 4c 28 t(normalizeHTML(
1050: 74 61 67 2e 72 6f 6f 74 2e 69 6e 6e 65 72 48 54 tag.root.innerHT
1060: 4d 4c 29 29 2e 74 6f 2e 62 65 2e 65 71 75 61 6c ML)).to.be.equal
1070: 28 27 3c 68 31 3e 48 65 6c 6c 6f 2c 20 66 72 6f ('<h1>Hello, fro
1080: 6d 20 74 68 65 20 70 61 72 65 6e 74 3c 2f 68 31 m the parent</h1
1090: 3e 3c 79 69 65 6c 64 2d 63 68 69 6c 64 3e 3c 68 ><yield-child><h
10a0: 31 3e 47 72 65 65 74 69 6e 67 3c 2f 68 31 3e 3c 1>Greeting</h1><
10b0: 69 3e 66 72 6f 6d 20 74 68 65 20 63 68 69 6c 64 i>from the child
10c0: 3c 2f 69 3e 3c 64 69 76 20 63 6c 61 73 73 3d 22 </i><div class="
10d0: 73 65 6c 65 63 74 65 64 22 3e 3c 62 3e 77 6f 6f selected"><b>woo
10e0: 68 61 3c 2f 62 3e 3c 2f 64 69 76 3e 3c 2f 79 69 ha</b></div></yi
10f0: 65 6c 64 2d 63 68 69 6c 64 3e 27 29 0a 0a 20 20 eld-child>')..
1100: 20 20 66 69 72 65 45 76 65 6e 74 28 24 28 27 69 fireEvent($('i
1110: 27 2c 20 74 61 67 2e 72 6f 6f 74 29 2c 20 27 63 ', tag.root), 'c
1120: 6c 69 63 6b 27 29 0a 0a 20 20 20 20 74 61 67 2e lick').. tag.
1130: 75 6e 6d 6f 75 6e 74 28 29 0a 0a 20 20 7d 29 0a unmount().. }).
1140: 0a 0a 0a 20 20 69 74 28 27 3c 79 69 65 6c 64 3e ... it('<yield>
1150: 20 63 6f 6e 74 65 6e 74 73 20 69 6e 20 61 20 6c contents in a l
1160: 6f 6f 70 20 67 65 74 20 61 6c 77 61 79 73 20 63 oop get always c
1170: 6f 6d 70 69 6c 65 64 20 75 73 69 6e 67 20 69 74 ompiled using it
1180: 73 20 70 61 72 65 6e 74 20 64 61 74 61 27 2c 20 s parent data',
1190: 66 75 6e 63 74 69 6f 6e 28 64 6f 6e 65 29 20 7b function(done) {
11a0: 0a 0a 20 20 20 20 69 6e 6a 65 63 74 48 54 4d 4c .. injectHTML
11b0: 28 5b 0a 20 20 20 20 20 20 27 3c 79 69 65 6c 64 ([. '<yield
11c0: 2d 6c 6f 6f 70 3e 27 2c 0a 20 20 20 20 20 20 27 -loop>',. '
11d0: 20 20 7b 20 67 72 65 65 74 69 6e 67 20 7d 27 2c { greeting }',
11e0: 0a 20 20 20 20 20 20 27 20 20 3c 64 69 76 3e 53 . ' <div>S
11f0: 6f 6d 65 74 68 69 6e 67 20 65 6c 73 65 3c 2f 64 omething else</d
1200: 69 76 3e 27 2c 0a 20 20 20 20 20 20 27 3c 2f 79 iv>',. '</y
1210: 69 65 6c 64 2d 6c 6f 6f 70 3e 27 0a 20 20 20 20 ield-loop>'.
1220: 5d 29 0a 0a 20 20 20 20 76 61 72 20 74 61 67 20 ]).. var tag
1230: 3d 20 72 69 6f 74 2e 6d 6f 75 6e 74 28 27 79 69 = riot.mount('yi
1240: 65 6c 64 2d 6c 6f 6f 70 27 2c 20 7b 0a 20 20 20 eld-loop', {.
1250: 20 20 20 20 20 73 61 79 53 6f 6d 65 74 68 69 6e saySomethin
1260: 67 3a 20 64 6f 6e 65 0a 20 20 20 20 20 20 7d 29 g: done. })
1270: 5b 30 5d 2c 0a 20 20 20 20 20 20 63 68 69 6c 64 [0],. child
1280: 33 0a 0a 20 20 20 20 65 78 70 65 63 74 28 74 61 3.. expect(ta
1290: 67 2e 74 61 67 73 5b 27 79 69 65 6c 64 2d 63 68 g.tags['yield-ch
12a0: 69 6c 64 2d 32 27 5d 2e 6c 65 6e 67 74 68 29 2e ild-2'].length).
12b0: 74 6f 2e 62 65 2e 65 71 75 61 6c 28 35 29 0a 0a to.be.equal(5)..
12c0: 20 20 20 20 63 68 69 6c 64 33 20 3d 20 74 61 67 child3 = tag
12d0: 2e 74 61 67 73 5b 27 79 69 65 6c 64 2d 63 68 69 .tags['yield-chi
12e0: 6c 64 2d 32 27 5d 5b 33 5d 0a 0a 20 20 20 20 65 ld-2'][3].. e
12f0: 78 70 65 63 74 28 63 68 69 6c 64 33 2e 72 6f 6f xpect(child3.roo
1300: 74 2e 67 65 74 45 6c 65 6d 65 6e 74 73 42 79 54 t.getElementsByT
1310: 61 67 4e 61 6d 65 28 27 68 32 27 29 5b 30 5d 2e agName('h2')[0].
1320: 69 6e 6e 65 72 48 54 4d 4c 2e 74 72 69 6d 28 29 innerHTML.trim()
1330: 29 2e 74 6f 2e 62 65 2e 65 71 75 61 6c 28 27 73 ).to.be.equal('s
1340: 75 62 74 69 74 6c 65 34 27 29 0a 0a 20 20 20 20 ubtitle4')..
1350: 66 69 72 65 45 76 65 6e 74 28 63 68 69 6c 64 33 fireEvent(child3
1360: 2e 72 6f 6f 74 2e 67 65 74 45 6c 65 6d 65 6e 74 .root.getElement
1370: 73 42 79 54 61 67 4e 61 6d 65 28 27 69 27 29 5b sByTagName('i')[
1380: 30 5d 2c 20 27 63 6c 69 63 6b 27 29 0a 0a 20 20 0], 'click')..
1390: 20 20 74 61 67 2e 75 6e 6d 6f 75 6e 74 28 29 0a tag.unmount().
13a0: 0a 20 20 7d 29 0a 0a 20 20 69 74 28 27 3c 79 69 . }).. it('<yi
13b0: 65 6c 64 3e 20 77 69 74 68 20 64 6f 6c 6c 61 72 eld> with dollar
13c0: 20 73 69 67 6e 73 20 67 65 74 20 72 65 70 6c 61 signs get repla
13d0: 63 65 64 20 63 6f 72 72 65 63 74 6c 79 27 2c 20 ced correctly',
13e0: 66 75 6e 63 74 69 6f 6e 28 29 20 7b 0a 0a 20 20 function() {..
13f0: 20 20 69 6e 6a 65 63 74 48 54 4d 4c 28 5b 0a 20 injectHTML([.
1400: 20 20 20 20 20 27 3c 79 69 65 6c 64 2d 77 69 74 '<yield-wit
1410: 68 2d 64 6f 6c 6c 61 72 2d 32 3e 27 2c 0a 20 20 h-dollar-2>',.
1420: 20 20 20 20 27 20 20 3c 79 69 65 6c 64 2d 77 69 ' <yield-wi
1430: 74 68 2d 64 6f 6c 6c 61 72 2d 31 20 63 6f 73 74 th-dollar-1 cost
1440: 3d 22 24 32 35 22 3e 3c 2f 79 69 65 6c 64 2d 77 ="$25"></yield-w
1450: 69 74 68 2d 64 6f 6c 6c 61 72 2d 31 3e 27 2c 0a ith-dollar-1>',.
1460: 20 20 20 20 20 20 27 3c 2f 79 69 65 6c 64 2d 77 '</yield-w
1470: 69 74 68 2d 64 6f 6c 6c 61 72 2d 32 3e 27 0a 20 ith-dollar-2>'.
1480: 20 20 20 5d 29 0a 0a 20 20 20 20 72 69 6f 74 2e ]).. riot.
1490: 74 61 67 28 27 79 69 65 6c 64 2d 77 69 74 68 2d tag('yield-with-
14a0: 64 6f 6c 6c 61 72 2d 31 27 2c 20 27 3c 73 70 61 dollar-1', '<spa
14b0: 6e 3e 7b 6f 70 74 73 2e 63 6f 73 74 7d 3c 2f 73 n>{opts.cost}</s
14c0: 70 61 6e 3e 27 29 0a 20 20 20 20 72 69 6f 74 2e pan>'). riot.
14d0: 74 61 67 28 27 79 69 65 6c 64 2d 77 69 74 68 2d tag('yield-with-
14e0: 64 6f 6c 6c 61 72 2d 32 27 2c 20 27 3c 79 69 65 dollar-2', '<yie
14f0: 6c 64 3e 3c 2f 79 69 65 6c 64 3e 27 29 0a 0a 20 ld></yield>')..
1500: 20 20 20 76 61 72 20 74 61 67 20 3d 20 72 69 6f var tag = rio
1510: 74 2e 6d 6f 75 6e 74 28 27 79 69 65 6c 64 2d 77 t.mount('yield-w
1520: 69 74 68 2d 64 6f 6c 6c 61 72 2d 32 27 29 5b 30 ith-dollar-2')[0
1530: 5d 0a 0a 20 20 20 20 65 78 70 65 63 74 28 6e 6f ].. expect(no
1540: 72 6d 61 6c 69 7a 65 48 54 4d 4c 28 74 61 67 2e rmalizeHTML(tag.
1550: 72 6f 6f 74 2e 69 6e 6e 65 72 48 54 4d 4c 29 29 root.innerHTML))
1560: 2e 74 6f 2e 62 65 2e 65 71 75 61 6c 28 27 3c 79 .to.be.equal('<y
1570: 69 65 6c 64 2d 77 69 74 68 2d 64 6f 6c 6c 61 72 ield-with-dollar
1580: 2d 31 20 63 6f 73 74 3d 22 24 32 35 22 3e 3c 73 -1 cost="$25"><s
1590: 70 61 6e 3e 24 32 35 3c 2f 73 70 61 6e 3e 3c 2f pan>$25</span></
15a0: 79 69 65 6c 64 2d 77 69 74 68 2d 64 6f 6c 6c 61 yield-with-dolla
15b0: 72 2d 31 3e 27 29 0a 0a 20 20 20 20 74 61 67 2e r-1>').. tag.
15c0: 75 6e 6d 6f 75 6e 74 28 29 0a 0a 20 20 7d 29 0a unmount().. }).
15d0: 0a 7d 29 0a .}).