- From: Frank Lemanschik <notifications@github.com>
- Date: Tue, 25 Aug 2020 23:00:26 -0700
- To: w3c/webcomponents <webcomponents@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <w3c/webcomponents/issues/716/680674835@github.com>
i am not sure but i want to say something as i am deep into this stuff since some years. Out of my View There should be no such customRegistry needed all that the current reg does is calling some hooks. we can archive that with custom conditions and mutation observer in round about 10 short lines of code. So if one has the need for handling elements with a custom lifecycle Mutation Observer is the way to go it supports all that. Some none tested code examples out of my head showing all 4 hooks ```js const attributesObserver = new MutationObserver(function(mutations, observer) { mutations.forEach(function(mutation) { if (mutation.type == "attributes") { attributeChangedCallback.apply(mutation.target,[mutation.attributeName, mutation.oldValue mutation.target.getAttribute(mutation.attributeName)]) } }); }); const childListObserver = new MutationObserver(function(mutations, observer) { mutations.forEach(function(mutation) { if (mutation.type === 'childList') { mutation.addedNodes.forEach(connectedCallback.apply) mutation.removededNodes.forEach(disconnectedCallback.apply) } }); }); attributesObserver.observe(el, { attributes: true, //configure it to listen to attribute changes attributeOldValue: true, attributeFilter: ['hidden', 'contenteditable', 'data-par'] // individual listen to attributes. }); childListObserver.observe(el.parent, { childList: true, subtree: true }); ``` -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/w3c/webcomponents/issues/716#issuecomment-680674835
Received on Wednesday, 26 August 2020 06:00:39 UTC