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

Unable to use ">" for getting direct child element. #71

Open
why2000 opened this issue Mar 28, 2024 · 0 comments
Open

Unable to use ">" for getting direct child element. #71

why2000 opened this issue Mar 28, 2024 · 0 comments

Comments

@why2000
Copy link

why2000 commented Mar 28, 2024

Describe the bug
With the getObject and getAllObject methods in querySelector.js, > symbol is removed in splitting, but never processed back and won't take effect. This causes all related Shadow.findElement(s) behaviors to be malfunctioning. See the following example:

To Reproduce
Steps to reproduce the behavior:

  1. Consider a following DOM:
<html>
  <div id="a">
      <div id="b">
         <div id="c"></div>
      </div>
      <div id="d"></div>
  </div>
  <script src="querySelector.js"></script>
</html>
  1. run getAllObject("div#a > div") in the console.
  2. Actual result is [<div id="b">, <div id="c">, <div id="d">], but #c is not a direct child of #a

Expected behavior
Expected result should be [<div id="b">, <div id="d">]

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: MacOS 13.6.4
  • Browser: Chrome 123 / Safari 17.3.1

Additional context

const multiLevelSelectors = splitByCharacterUnlessQuoted(selector, '>');

I don't understand why > is used to process multi-level DOM.
For functional, this is not needed at all, since without splitting, the script still works fine for piercing through multi-level shadow roots.
For performance, if we have to use some symbol to reduce the max size of possible elements cached in the allElements array, & would be a much better choice considering only one character is allowed in splitByCharacterUnlessQuoted.

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

No branches or pull requests

1 participant