Skip to content

fix: correct VendorPrefix for ::-ms-input-placeholder pseudo-element - #1281

Open
Noethix55555 wants to merge 1 commit into
parcel-bundler:masterfrom
Noethix55555:fix/ms-input-placeholder
Open

fix: correct VendorPrefix for ::-ms-input-placeholder pseudo-element#1281
Noethix55555 wants to merge 1 commit into
parcel-bundler:masterfrom
Noethix55555:fix/ms-input-placeholder

Conversation

@Noethix55555

Copy link
Copy Markdown

src/selector.rs line 294 maps the ::-ms-input-placeholder pseudo-element to VendorPrefix::Moz instead of VendorPrefix::Ms — a copy-paste error from the line above (-moz-placeholder).

The serializer at line 1244 branches on the stored prefix:

Placeholder(prefix) => {
    let vp = write_prefix!(prefix);
    if vp == VendorPrefix::WebKit || vp == VendorPrefix::Ms {
        dest.write_str("input-placeholder")
    } else {
        dest.write_str("placeholder")
    }
}

Because the stored prefix is Moz, the wrong branch fires: the -moz- vendor prefix is written, and placeholder (not input-placeholder) is appended. Any stylesheet that already contains ::-ms-input-placeholder is silently rewritten to ::-moz-placeholder — a completely different selector.

Repro:

input::-ms-input-placeholder { color: red; }

Before this fix, lightningcss outputs:

input::-moz-placeholder{color:red}

After this fix:

input::-ms-input-placeholder{color:red}

Fix: change VendorPrefix::Moz to VendorPrefix::Ms on line 294. Three round-trip minify_test assertions are added to prevent regression.

Parsing ::-ms-input-placeholder stored VendorPrefix::Moz instead of
VendorPrefix::Ms. The serializer checks for Moz vs WebKit/Ms to decide
whether to emit 'input-placeholder' or 'placeholder', so a round-tripped
::-ms-input-placeholder was silently rewritten to ::-moz-placeholder.

Add minify_test round-trip assertions for the three vendor-prefixed
placeholder pseudo-elements to guard against regression.
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

Successfully merging this pull request may close these issues.

1 participant