3 ms·
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 - s
by ry_ry 9y ago
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?
- Arnt 9y agoYou 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.
- myhf 9y agoThere is some discussion about the motivation here: http://www.backalleycoder.com/2012/04/25/i-want-a-damnodeinserted/ http://www.backalleycoder.com/2012/04/25/i-want-a-damnodeins...
- ry_ry 9y agoOh 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".
- atmin 9y agoAnd implementation by the same author: https://github.com/csuwildcat/SelectorListener https://github.com/csuwildcat/SelectorListener
- daurnimator 9y agoFor 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