Skip to content

Commit

Permalink
Fix 4387. Ensure dom-change fired with composed: true.
Browse files Browse the repository at this point in the history
  • Loading branch information
Steven Orvell committed Mar 7, 2017
1 parent 8fd1b21 commit 3e68329
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 3 deletions.
5 changes: 4 additions & 1 deletion lib/elements/dom-bind.html
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,10 @@
this._flushProperties();
}
this.__insertChildren();
this.dispatchEvent(new CustomEvent('dom-change', {bubbles: true}));
this.dispatchEvent(new CustomEvent('dom-change', {
bubbles: true,
composed: true
}));
}

}
Expand Down
5 changes: 4 additions & 1 deletion lib/elements/dom-if.html
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,10 @@
this._showHideChildren();
}
if (this.if != this._lastIf) {
this.dispatchEvent(new CustomEvent('dom-change', {bubbles: true}));
this.dispatchEvent(new CustomEvent('dom-change', {
bubbles: true,
composed: true
}));
this._lastIf = this.if;
}
}
Expand Down
5 changes: 4 additions & 1 deletion lib/elements/dom-repeat.html
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,10 @@
// Set rendered item count
this._setRenderedItemCount(this.__instances.length);
// Notify users
this.dispatchEvent(new CustomEvent('dom-change', {bubbles: true}));
this.dispatchEvent(new CustomEvent('dom-change', {
bubbles: true,
composed: true
}));
// Check to see if we need to render more items
this.__tryRenderChunk();
}
Expand Down
13 changes: 13 additions & 0 deletions test/unit/dom-if.html
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,19 @@
assert.equal(stamped[2].prop, 'nice');
});

test('dom-change event composed, bubbles outside dom-if scope', function() {
var domChangeFired = 0;
var domIf = configured.$['if-1'];
configured.addEventListener('dom-change', function() {
domChangeFired++;
});
domIf.if = !domIf.if;
domIf.render();
domIf.if = !domIf.if;
domIf.render();
assert.equal(domChangeFired, 2);
});

});

suite('nested individually-controlled dom-if', function() {
Expand Down
16 changes: 16 additions & 0 deletions test/unit/dom-repeat.html
Original file line number Diff line number Diff line change
Expand Up @@ -4098,6 +4098,22 @@ <h4>x-repeat-chunked</h4>

});

suite('dom-change composed', function() {

test('dom-change event composed, bubbles outside dom-if scope', function() {
var el = fixture('simple');
var domChangeFired = 0;
el.addEventListener('dom-change', function() {
domChangeFired++;
});
el.push('items', {prop: 'added1'});
Polymer.flush();
el.push('items', {prop: 'added2'});
Polymer.flush();
assert.equal(domChangeFired, 2);
});
})

})();
</script>

Expand Down

0 comments on commit 3e68329

Please sign in to comment.