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

:scope can't distinguish a context with no IDs nor classnames #96

Open
b-fuze opened this issue Aug 18, 2023 · 0 comments
Open

:scope can't distinguish a context with no IDs nor classnames #96

b-fuze opened this issue Aug 18, 2023 · 0 comments

Comments

@b-fuze
Copy link

b-fuze commented Aug 18, 2023

Here's a basic example that should work in a browser:

<html>
  <head>
    <script src="./nwsapi-2.2.7.js"></script>
    <script type="module">
      const parent = document.querySelector("div");
      console.log("NWSAPI", [...NW.Dom.select(":scope > div", parent)].map(d => d.className));
      console.log("NATIVE", [...parent.querySelectorAll(":scope > div")].map(d => d.className));
    </script>
  </head>
  <body>
    <div>
      <div class=outer>
        <div class=inner></div>
      </div>
      <div class=other-outer></div>
    </div>
  </body>
</html>

The output that I get:

NWSAPI Array [ "outer", "inner", "other-outer" ]
NATIVE Array [ "outer", "other-outer" ]

NWSAPI incorrectly selects the div with the inner classname while the browser correctly excludes that div, since it's not a direct child of the parent/context div.

The bug is due to makeref relying on classnames and/or ID's to distinguish the parent/context element from the children

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