Re:Show HN: SentinelJS – Detect new DOM nodes using CSS sele...
by ry_ry on Monday September 18, 2017 @05:13AM
(#15274390)
I might be missing a very obvious use-case here (3rd party scripts, perhaps?) but surely if a new DOM node is inserted, you most likely actioned it yourself - so why not set the innerHTML at that point?
[ Parent
| on HN ]
Re:Show HN: SentinelJS – Detect new DOM nodes using CSS sele...
by myhf on Monday September 18, 2017 @05:23AM
(#15274424)
There is some discussion about the motivation here:
http://www.backalleycoder.com/2012/04/25/i-want-a-damnodeins...
Re:Show HN: SentinelJS – Detect new DOM nodes using CSS sele...
by atmin on Monday September 18, 2017 @05:50AM
(#15274527)
And implementation by the same author: https://github.com/csuwildcat/SelectorListener
Re:Show HN: SentinelJS – Detect new DOM nodes using CSS sele...
by ry_ry on Monday September 18, 2017 @05:35AM
(#15274468)
Oh nice, thanks.
I'd actually completely forgotten about mutation observers too - they'd got mentally filed away under "browser vendors are why we can't have nice things".
Re:Show HN: SentinelJS – Detect new DOM nodes using CSS sele...
by Arnt on Monday September 18, 2017 @05:17AM
(#15274405)
You used npm to pull in nine hundred dependencies. One of them made the new node, and you want to know.
Or you're writing one of the nine hundred, and the user made the node.
Re:Show HN: SentinelJS – Detect new DOM nodes using CSS sele...
by daurnimator on Monday September 18, 2017 @08:26AM
(#15275221)
For fengari-web[1] we want to watch for <script type="text/lua"> tags inserted into the document.
At the moment we use a MutationObserver[2], but I should compare the speed of things. I've created a new issue to track[3]
[1] https://github.com/fengari-lua/fengari-web
[2] https://github.com/fengari-lua/fengari-web/blob/4279f4b3aec063062eb8baf68a065ee5b0c1d7c6/src/fengari-web.js#L132
[3] https://github.com/fengari-lua/fengari-web/issues/15