Switch from attribute+observer to bubbling events for comms

This commit is contained in:
Ian Gulliver
2019-07-16 16:05:29 +00:00
parent 329727ff9e
commit ccf4299d5a
3 changed files with 25 additions and 14 deletions

View File

@@ -54,7 +54,8 @@ class EditorEntryBase extends ListenUtils {
elem.classList.toggle('highlight', highlight);
}
// Do NOT refresh: this bypasses the rendering pipeline
this.elem_.setAttribute('data-arch-snapshot', '');
this.elem_.dispatchEvent(
new CustomEvent('snapshotRequest', { bubbles: true }));
}
toggleHighlight() {
@@ -78,6 +79,11 @@ class EditorEntryBase extends ListenUtils {
afterDomAdd() {
}
requestRender() {
this.elem_.dispatchEvent(
new CustomEvent('renderRequest', { bubbles: true }));
}
static addBefore(container, elem, ...rest) {
let entry = new this(null, ...rest);
container.insertBefore(entry.getElement(), elem);