WebReflection / linkedom

A triple-linked lists based DOM implementation.
https://webreflection.medium.com/linkedom-a-jsdom-alternative-53dd8f699311
ISC License
1.62k stars 78 forks source link

`querySelectorAll` breaks when the DOM contains an element with a 'template' attribute #262

Closed omril1 closed 4 months ago

omril1 commented 4 months ago
const html = parser.parseFromString(`<div template="this content breaks querySelector">😊</div>`, 'text/html').documentElement;

html.querySelectorAll('*'); // throws TypeError: Cannot read properties of undefined (reading 'nodeType')

The cause seems to be next = next.localName === 'template' ? next[END] : next[NEXT];

I assume the check with localName should happen only if next is an ELEMENT_NODE and not an attribute as the code there was meant for template elements

WebReflection commented 4 months ago

It's up, thank you 👋