Skip to content

Commit 1fa4948

Browse files
committed
Add example of overriding suppressTemplateNotifications via notify-dom-change.
1 parent d9c18b4 commit 1fa4948

File tree

1 file changed

+35
-1
lines changed

1 file changed

+35
-1
lines changed

CHANGELOG.md

+35-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,41 @@ This update to Polymer includes some new [global settings](https://polymer-libra
117117

118118
**What does it do?** This setting causes `<dom-if>` and `<dom-repeat>` not to dispatch `dom-change` events when their rendered content is updated. If you're using lots of `<dom-if>` and `<dom-repeat>` but not listening for these events, this setting lets you disable them and their associated propagation work.
119119

120-
You can override the global setting on an individual `<dom-if>` or `<dom-repeat>` by setting its `notify-dom-change` boolean attribute.
120+
You can override the global setting for an individual `<dom-if>` or `<dom-repeat>` by setting its `notify-dom-change` boolean attribute:
121+
122+
```js
123+
import {PolymerElement, html} from '@polymer/polymer/polymer-element.js';
124+
125+
class SomeElement extends PolymerElement {
126+
static get properties() {
127+
return {
128+
visible: {type: Boolean, value: false},
129+
};
130+
}
131+
132+
static get template() {
133+
return html`
134+
<button on-click="_toggle">Toggle</button>
135+
<!-- Set notify-dom-change to enable dom-change events for this particular <dom-if>. -->
136+
<dom-if if="[[visible]]" notify-dom-change on-dom-change="_onDomChange">
137+
<template>
138+
Hello!
139+
</template>
140+
</dom-if>
141+
`;
142+
}
143+
144+
_toggle() {
145+
this.visible = !this.visible;
146+
}
147+
148+
_onDomChange(e) {
149+
console.log("Received 'dom-change' event.");
150+
}
151+
}
152+
153+
customElements.define('some-element', SomeElement);
154+
```
121155

122156
**Should I use it?** This setting is generally recommended.
123157

0 commit comments

Comments
 (0)