Repository navigation
Fix name attributes in CSS selector hovers - #545
Xnerv Wang (xnervwang) wants to merge 1 commit into
Conversation
|
@microsoft-github-policy-service agree |
Martin Aeschlimann (aeschli)
left a comment
There was a problem hiding this comment.
Integration note: synchronize #546 with the new label-name storage
This PR looks correct independently, but please coordinate with #546 before merging both. #546 adds a LabelElement.clone() implementation that still reads findAttribute("name"); this PR changes label-name storage to ELEMENT_NAME (<>). The combination therefore clones a null label.
For .foo ~ .bar { .baz & { color: red; } }, the combined preview contains literal null instead of ⋮; descendant placeholders can also lose …. Both CSS and SCSS sibling-reference tests fail in the combined suite, although each PR passes separately.
The detailed reproduction/fix request is also posted on #546. Updating its clone lookup to the same storage key resolves the mismatch; this is not a request to revert the [name] fix here.
Reviewed commit: 5b3751b.
The hover for
[name="jmeno"]shows<jmeno>instead of<element name="jmeno">.input[name="jmeno"]shows<input jmeno>, andinput[name]shows<input undefined>. Other attributes, such as[names="jmeno"], display correctly.The
Elementclass insrc/services/selectorPrinting.tsstores the element name in its attribute list under the keyname, which collides with a realnameattribute. In the earlier PR #299, aeschli identified this collision and suggested a separate property or a key such as<>that is not a valid attribute name.This change stores the element name under a new
ELEMENT_NAMEconstant with the value<>. The name stays at the same position in the attribute list, so the Sass&handling for&__barand prefixes before&, which appends to the last entry and prepends to the first, works as before.An escaped attribute name that decodes to
<>, such as[\<\>=x], now collides with the key and displays as<x>instead of the previous<element <>="x">.New tests cover the reported
[name="jmeno"]selector and an SCSS rule nested ino1[name=x]; they fail onmain. With the change, they pass along with the rest ofnpm test.Fixes microsoft/vscode#160987.