Skip to content

Commit

Permalink
closes #1803
Browse files Browse the repository at this point in the history
  • Loading branch information
GianlucaGuarini committed May 22, 2016
1 parent cbdafa4 commit 70913ff
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/browser/tag/tag.js
Expand Up @@ -29,7 +29,9 @@ function Tag(impl, conf, innerHTML) {
// it could be handy to use it also to improve the virtual dom rendering speed
defineProperty(this, '_riot_id', ++__uid) // base 1 allows test !t._riot_id

extend(this, { parent: parent, root: root, opts: opts, tags: {} }, item)
extend(this, { parent: parent, root: root, opts: opts}, item)
// protect the "tags" property from being overridden
defineProperty(this, 'tags', {})

// grab attributes
each(root.attributes, function(el) {
Expand Down
6 changes: 6 additions & 0 deletions test/specs/browser/compiler.js
Expand Up @@ -1126,6 +1126,12 @@ describe('Compiler Browser', function() {
tags.push(tag)
})

it('protect the internal "tags" attribute from external overrides', function() {
var tag = riot.mount('loop-protect-internal-attrs')[0]
expect(tag.tags['loop-protect-internal-attrs-child'].length).to.be(4)
tags.push(tag)
})

it('preserve the mount order, first the parent and then all the children', function() {
var correctMountingOrder = [
'deferred-mount',
Expand Down
2 changes: 2 additions & 0 deletions test/specs/browser/tags-bootstrap.js
Expand Up @@ -84,6 +84,8 @@ loadTagsAndScripts([

'tag/obj-key-loop.tag',

'tag/loop-protect-internal-attrs.tag',

'tag/loop-svg-nodes.tag',

// these tags will be not autoinjected in the DOM
Expand Down
17 changes: 17 additions & 0 deletions test/tag/loop-protect-internal-attrs.tag
@@ -0,0 +1,17 @@

<loop-protect-internal-attrs>

<div each={ items }>
<loop-protect-internal-attrs-child></loop-protect-internal-attrs-child>
</div>

this.items = [
{ foo: 'foo', tags: 'tags' },
{ foo: 'foo', tags: 'tags' },
{ foo: 'foo', tags: 'tags' },
{ foo: 'foo', tags: 'tags' }
]

</loop-protect-internal-attrs>

<loop-protect-internal-attrs-child></loop-protect-internal-attrs-child>

0 comments on commit 70913ff

Please sign in to comment.