ginader / HTML5-placeholder-polyfill

Small and robust polyfill for the HTML5 placeholder attribut.
GNU General Public License v2.0
223 stars 85 forks source link

Does this support :placeholder-shown? #71

Closed corysimmons closed 8 years ago

corysimmons commented 8 years ago

It'd be awfully sweet if it did. :O

ginader commented 8 years ago

Hey Cory, thanks for the great suggestion! I agree it would indeed be rather sweet! It is, however, sadly impossible to polyfill the exact :syntax. What I can and will do is to apply a class .placeholder-shown instead. I'll implement this ASAP. Wouldn't that be awefully sweet as well? On Feb 25, 2016 7:24 PM, "Cory Simmons" notifications@github.com wrote:

It'd be awfully sweet if it did. :O

— Reply to this email directly or view it on GitHub https://github.com/ginader/HTML5-placeholder-polyfill/issues/71.

corysimmons commented 8 years ago

I suppose.

How does Selectivizr and stuff work if we can't polyfill pseudos?

ginader commented 8 years ago

What Selectivizr is doing is to read all the linked stylesheets and duplicate the rules that apply to the pseudo selectors and then rewrite the CSS. This works only with CSS linked from the same domain (so it would fail from CDNs). While this "somewhat works" it's rather flaky (check the last paragraph on http://selectivizr.com/ ). I prefer this to be robust. On Feb 25, 2016 10:44 PM, "Cory Simmons" notifications@github.com wrote:

I suppose.

How does Selectivizr and stuff work if we can't polyfill pseudos?

— Reply to this email directly or view it on GitHub https://github.com/ginader/HTML5-placeholder-polyfill/issues/71#issuecomment-189132113 .

corysimmons commented 8 years ago

I think .placeholder-shown can work. Re-implementing a selector engine just for this seems like overkill. So syntax would work like:

input {
  &.placeholder-shown,
  &:placeholder-shown {
    background: orange;
  }
}

?

ginader commented 8 years ago

Exactly! I think this would be very elegant :-)

ginader commented 8 years ago

See the new readme section here to see how to use it: https://github.com/ginader/HTML5-placeholder-polyfill#customizing-the-styling-optional

corysimmons commented 8 years ago

Awesome. Will be featuring your lib on TutsPlus this upcoming week. Thanks. =)

ginader commented 8 years ago

Woohoo! thanks @corysimmons :-)

corysimmons commented 8 years ago

No problem. Thanks for being an active/good maintainer. :+1: :100: