querySelectorAll attribute selector does not match empty string when dynamically updated

Confirmed Issue #12463893 • Assigned to Jose L.

Details

Author
Milan R.
Created
Jun 23, 2017
Privacy
This issue is public.
Found in
  • Microsoft Edge
Found in build #
15.15063
Reports
Reported by 2 people

Sign in to watch or report this issue.

Steps to reproduce

Overview

When the following element exists in the DOM Explorer:

<ni-label data-ni-base-style="uninitialized" ni-control-id="29" text="Numeric" label-id="" binding-info="{}" vi-ref="" control-id=""></ni-label>

The following attribute selector for an attribute with value empty string fails to locate it:

[vi-ref=""][ni-control-id="29"]

This behavior is a regression in EdgeHTML 15. It does not occur in EdgeHTML 14 and below, IE11, or in the latest stable Safari, Firefox, or Chrome.

Reproduction

I was able to make the attached stand-alone test case that reproduces the behavior consistently.

In the attached test case a script was added to run at different points and print to the console log to illustrate the query selector behavior.

First a script will run synchronously in the HEAD. As expected no elements are found in the DOM.

Second a script will run after DOMContentLoaded. At this point the element exists in the DOM but the vi-ref attribute has value null. This is because the attribute is set by JS in the future. As expected the element can be found on its own, but not with the query selector above.

Third the script runs synchronously after the vi-ref attribute is updated to empty string in JS. At this point I would expect the above selector to find the element, however the query selector above does not find it. The element attribute can be manually queried to verify that it is the value empty string.

Fourth the script runs after several seconds. The selector still fails to find the element. It can be seen in the DOM Explorer that the element does have the vi-ref attribute but selection still fails.

An example console log from a test execution (slightly cleaned up) is as follows:

HTML1300: Navigation occurred.
Main.html
Current window: localhost/Main.html
[Test Run 0]  expected result: [sync load] No elements should be found
[Test Run 0]  element not found in dom yet
[Test Run 0]  original selector elements length: 0
[Test Run 0]  workaround selector ignoring empty attribute string: 0
[Test Run 0]  workaround manually checking attribute value for empty string: 0
dom state: interactive
asm.js has been disabled as the script debugger is connected. Disconnect the debugger to enable asm.js.
vireo.js
DOMContentLoaded
[Test Run 1]  expected result: [DOMContentLoaded] the attribute is not on the element yet, but the element exists and attribute is null
[Test Run 1]  current vi-ref attribute of element: null
[Test Run 1]  original selector elements length: 0
[Test Run 1]  workaround selector ignoring empty attribute string: 0
[Test Run 1]  workaround manually checking attribute value for empty string: 0
dom state: complete
[Test Run 2]  expected result: [defer load] The vi-ref attribute has been updated, all selectors should be active
[Test Run 2]  current vi-ref attribute of element: empty string
[Test Run 2]  original selector elements length: 0
[Test Run 2]  workaround selector ignoring empty attribute string: 1
[Test Run 2]  workaround manually checking attribute value for empty string: 1
SCRIPT5022: Element with niControlId=29 must have a unique niControlId to be registered to this VI
niModelsAndViewModels.min.js (3,2717)
[Test Run 3]  expected result: [5 seconds into page load] original selector remains non-functional eventhough attribute text is empty string
[Test Run 3]  current vi-ref attribute of element: empty string
[Test Run 3]  original selector elements length: 0
[Test Run 3]  workaround selector ignoring empty attribute string: 1
[Test Run 3]  workaround manually checking attribute value for empty string: 1

Attachments

Comments and activity

  • Microsoft Edge Team

    Changed Assigned To to “James M.”

    Changed Assigned To to “Travis L.”

    Changed Assigned To from “Travis L.” to “Jose L.”

    Changed Status to “Confirmed”

You need to sign in to your Microsoft account to add a comment.

Sign in