Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Throw a better error when documentElement is missing #458

Open
mgol opened this issue Aug 26, 2019 · 1 comment
Open

Throw a better error when documentElement is missing #458

mgol opened this issue Aug 26, 2019 · 1 comment

Comments

@mgol
Copy link
Member

mgol commented Aug 26, 2019

PR #439 made Sizzle crash earlier on a documentElement-missing document. However, we want selection to work on nodes inside of a <template> element for which ownerDocument will point to a document fragment with a null documentElement. As @gibson042 said in #452:

We discussed in-meeting and had rough consensus that the right behavior was to stop at a disconnected fragment but to traverse up through a fragment's <template> host when one exists. But unfortunately, it seems difficult and maybe impossible to differentiate the two. My ideal change would instead be to tolerate null documentElement, but more changes will be required for that.

@mgol
Copy link
Member Author

mgol commented Sep 7, 2023

For the record, the same code exists in jQuery 3.x:
https://github.com/jquery/jquery/blob/f79d5f1a337528940ab7029d4f8bbba72326f269/src/selector.js#L505-L512
but we're unlikely to touch it there. jQuery 4.x code already doesn't have this check:
https://github.com/jquery/jquery/blob/42e50f8c21fbfd08092ad81add4ac38982ef0841/src/selector.js#L325-L332
and it doesn't result in an automatic crash as setDocument in jQuery 4.x will be much, much simpler.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant