Open Loirooriol opened 7 months ago
The latter seems better, right?
The first seems more appropriate and easier to implement.
I suspect this may not be web compatible at this point.
Why authors would use .setProperty()
instead of .removeProperty()
to remove a declaration?
@cdoublev I imagine authors using jQuery like
$(".foo").css({
display: "block",
"--foo": "",
})
which I think ends up using https://github.com/jquery/jquery/blob/527fb3dcf0dcde69302a741dfc61cbfa58e99eb0/src/css.js#L253C1-L257C6
if ( isCustomProp ) {
style.setProperty( name, value );
} else {
style[ name ] = value;
}
Ok. They expect property values that include var(--foo)
to become invalid. I cannot say how many would remain invalid if it was substituted with an empty string.
I would expect the JS to be no-op as per the round-tripping principle.
However, an empty string has a special meaning in
setProperty
: it behaves asremoveProperty
, even though it's valid for custom properties.Some reasonable possibilities:
setProperty
toremoveProperty
for custom properties, since empty string is a valid value. Authors could explicitly useremoveProperty
if they want to remove. I suspect this may not be web compatible at this point." "
instead of""
so that they can be safely used insetProperty
, as @prjnt proposed in https://github.com/w3c/csswg-drafts/issues/774#issuecomment-515329876