-
Notifications
You must be signed in to change notification settings - Fork 308
Conversation
One way to do isomorphic prefixing would be to detect the browser on the server via user agent and do the prefixing using a known list or tool, like autoprefixer. |
We should probably also include support for the old-style flexbox syntax: https://css-tricks.com/using-flexbox/ |
Won't handle static site generation, but that's not a particularly common use case I guess. I'm good with this for now. Can re-evaluate later if it's a problem. |
When you say, "good with this", do you mean the current approach or the proposed approach? Should we merge this PR? |
Sorry yeah, feel free to merge this. 👍 |
Add automatic vendor prefixing
var prefix = function (style, mode /* 'css' or 'js' */) { | ||
mode = mode || 'js'; | ||
var newStyle = {}; | ||
Object.keys(style).forEach(function (property) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is unnecessary since it runs in the browser. You can test all prefixes and once you found one that works, it becomes the prefix for the rest of the session.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I'm not following you. What part is unnecessary? The code determines the prefix at the top of the file, and caches the result for individual properties/values.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh apologies, I was completely misreading this. Need more coffee 💩
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hah no problem. Thanks much for taking a look!
"Won't handle static site generation" |
@wenbing handling static site generation means adding 2MB of databases and code. Just post-process the generated HTML with https://github.com/postcss/autoprefixer on the server. |
Reopening #109 after deleting base wrap-api branch :(
Add some simple prefixing capability, based on css-vendor. Don't use css-vendor directly, though, to avoid going back and forth between dash-case and camelCase. Also, be smarter than css-vendor about valid values that the browser rewrites.
While this approach works quite well, it falls down a bit for values that require complex prefixing. PrefixFree is much more comprehensive. For example, it will prefix values inside of transition, rewrite linear-gradient, and more.
Comment from @alexlande: