Closed atirip closed 5 years ago
you should simply write a script that points to hyperHTML and bind that hyperHTML created for that realm/window/document
Mhm, that is the hard solution I tried to avoid, as now I just import hyperHTML, but that way I need to pass (creating hyperHTML for every iframe is easy) that reference to every object that renders.
the only (currently) unsupported thing at this point is that nodes with connected
and disconnected
events won't work as expected. If that's not an issue, you can just bind foreigner bodies, 'cause that's done already in my Shadow DOM light poly https://github.com/WebReflection/attachshadow
would that be enough ?
Found solution, I guess, at least my code started working as expected. Inside wire()
all nodes are created for current document
and therefore all share same ownerDocument
, they get added, but no observer for iframes is created yet. I do need to modify disconnect()
this way:
var documents = new WeakSet();
return function observe(node) {
if (!documents.has(node.ownerDocument)) {
documents.add(node.ownerDocument);
startObserving(node.ownerDocument);
}
observer.add(node);
return node;
};
And then call:
observe(context.ownerDocument.documentElement);
inside bind()
which crerates observer, this is safe as I do only bind to bodies. No problem. I can live with that as of now. I have some other my own modifications anyway. Thanks.
why don't you file PRs instead?
If you think that is ok, then yes, I will. But I do think that this is just unnessesary code for the 99.99%.
Why, this is pretty obvious - startObserving() is called only for the first node with ownerDocument that this node may have. I do realize that this issue of mine may ever be only my issue. What I do is I create iframes dynamically and document.write the contents in, then bind stuff to body. So, I could try to modify the code and to start observing for all the different ownerDocuments I may encounter (a lot). I would just appreciate quick reply if this could be doable without some nasty side effects?