Fix insertAdjacentHTML and createContextualFragment not working on non-HTML documents#307
Fix insertAdjacentHTML and createContextualFragment not working on non-HTML documents#307WebReflection merged 9 commits intoWebReflection:mainfrom Gudine:main
Conversation
|
Thanks for the suggestion! I implemented it to the best of my understanding, though it is still O(n) because of the parent loop. Also, in the process I added JSDoc to the function, which ended up changing the type of |
there is O(n) and O(n) but the whole point in there is that you don't need to bloat RAM and pressure GC with clones and logic that is one shot away so this latest change is the way to go in LinkeDOM, if I took the everything is O(n) anyway approach in here it would be deadly slow, I hope this follow up makes sense to you ... I'll try to find time to review, check/test and publish this MR today or tomorrow. |
|
@Gudine it's up and running: thank you 🥳 |
The functions
Element.insertAdjacentHTMLandRange.createContextualFragmentresulted in crashes when used in XML documents, as they both rely on functionality from thetemplateHTML element, which only works in HTML documents. I fixed the issue by adapting the logic used inHTMLTemplateElementinto a separate utility function.To test this, I've moved some tests from
html/element.jstointerface/element.js, as they don't apply just to HTML elements.I'm not sure how feasible it would be, and it is out of scope of this PR, but it might also make sense to make the interface tests run on all three document types, as such tests would've caught both errors fixed here.