LeaVerou / prefixfree

Break free from CSS prefix hell!
http://projects.verou.me/prefixfree/
MIT License
3.83k stars 712 forks source link

Unhandled: :matches, stretch, sticky #6130

Open joyously opened 6 years ago

joyously commented 6 years ago

Looking through the tables at http://www.caniuse.com/#cats=CSS, I see these 3 things:

LeaVerou commented 6 years ago

We can't do anything for the first one (since -prefix-free only adds a prefix, doesn't rewrite), but would accept PRs for the others :)

joyously commented 6 years ago

Wouldn't changing stretch to -moz-available be a rewrite also? And it looked to me like the selectors are set up to handle changes, like placeholder does.

LeaVerou commented 6 years ago

Yeah, I guess we have deviated from the original premise :) No strong opinions there, if you can implement it in a sane way, I'd merge it.

joyously commented 5 years ago

I was looking in to how to add :matches and :is, but this code seems to be doing something odd.

for(var selector in selectors) {
    var standard = selectors[selector] || selector
    var prefixed = selector.replace(/::?/, function($0) { return $0 + self.prefix })
    if(!supported(standard) && supported(prefixed)) {
        self.selectors.push(standard);
        self.selectorMap[standard] = prefixed;
    }
}

It gets the standardized selector and checks if that is supported instead of checking if the non-standard one is supported. So if the stylesheet has :input-placeholder it remains untouched since it checked for ::placeholder being supported. Is this the intended logic? Is this supposed to leave an unsupported style alone, in case it is followed by the supported one? Or should the selector being saved be the actual selector that is prefixed, not the standardized one? Would this make more sense?

for(var selector in selectors) {
    var standard = selectors[selector] || selector
    var prefixed = selector.replace(/::?/, function($0) { return $0 + self.prefix })
    if(!supported(standard) && supported(prefixed)) {
        self.selectors.push(selector);
        self.selectorMap[selector] = prefixed;
    }
}
joyously commented 5 years ago

I think I'm understanding this better now. I got onto a tangent trying to do :matches since it is a rewrite, so was looking at the others that way. Sorry!

But, leaving the original code alone, doesn't the list of selectors hold the one that should be used to build the prefix, and the standard to check for? So maybe it's a different issue, but I'm thinking the list should look more like this

    '::placeholder': null,
    ':placeholder': ':placeholder-shown',
    '::input-placeholder': '::placeholder',
    ':input-placeholder': ':placeholder-shown',

I started typing this and forgot... So I opened a different issue (#6143) for the :placeholder-shown problem. If it's merged before the others that add to that list it won't interfere.