Skip to content
This repository has been archived by the owner on Aug 9, 2019. It is now read-only.

Consider using MutationObserver #2

Closed
thebuilder opened this issue Dec 20, 2017 · 3 comments
Closed

Consider using MutationObserver #2

thebuilder opened this issue Dec 20, 2017 · 3 comments

Comments

@thebuilder
Copy link

thebuilder commented Dec 20, 2017

Reading https://world.episerver.com/blogs/john-philip-johansson/dates/2017/12/taking-more-control-of-client-side-rendering-in-ope-beta2/ i'm wondering if the detection couldn't be solved by using a MutationObserver.

You can use it to keep track of all nodes with data-epi-property-name, even if they are dynamically added. It can also monitor for changes to data (Like if it's changed with content-editable), but i think reading the value when opening the overlay would make sense/reduce the performance overhead.

Very basic example of how MutationObserver could detect changes:

Edit nz7lnp5k0

@ghost
Copy link

ghost commented Jan 4, 2018

Yes you are correct, the problem could be solved with mutation observers. I actually did a proof of concept on this over a year ago. Unfortunately it has never made it into the product.

With regards to JP's blog post I'm not really sure why it was decided to publish an event. I'm guessing it was an approach that required less changes in our core editing classes. Also, to keep consistency with the previous changes that have been done in this area.

@ghost
Copy link

ghost commented Feb 12, 2018

Here is a gist for a way of using mutation observers in your partner templates https://gist.github.com/ben-mckernan/774ae408d19babd4d5c7547b4c9aa8a4

It handles calling the event described in JP's blog post. Maybe not exactly what you had in mind but I don't think we will be moving this into the product just yet.

@seriema
Copy link
Contributor

seriema commented Aug 9, 2019

Stale.

@seriema seriema closed this as completed Aug 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants