Skip to content

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

Closed
@b-fuze

Description

@b-fuze

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions