New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Shorthand syntax #41
Shorthand syntax #41
Conversation
@@ -37,7 +37,7 @@ a { | |||
|
|||
|
|||
/*styles for 620px and up! (let's try this one minified )*/ | |||
@media screen and (min-width: 620px),only print,projector{body{background:red;}} | |||
@media screen and (min-width: 620px),only print,projection{body{background:red;}} |
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.
"projector" is not a valid media type. Changed it to "projection" instead.
…g invalid media types as type "all"
@@ -115,8 +115,10 @@ | |||
|
|||
for( ; j < eql; j++ ){ | |||
thisq = eachq[ j ]; | |||
type = thisq.match( /(only\s+)?((?:\()|([a-zA-Z]+))(?:\sand)?/ ); | |||
type = (!type[3]) ? "all" : (type[1]) ? type[1] + type[2] : type[2]; |
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.
Example: @media (min-width: 900px)
Regex matches: ["(", undefined, "(", undefined]
type = "all"
Example: @media screen and (min-width: 900px)
Regex matches: ["screen and", undefined, "screen", "screen"]
type = "screen"
Example: @media only screen and (min-width: 900px)
Regex matches: ["only screen and", "only", "screen", "screen"]
type = "only screen"
+1 |
Thanks, Steve! and added a unit test, updated the min file. I don't have IE on me right now, so I can't test if it's passing or not. Mind giving it a look? Otherwise, looks good and I should be able to bring this in this week. |
Excellent. The tests are 100% passing in IE7 and IE8. A couple of notes:
|
The media query recommendation defines a shorthand syntax in Example V.
Essentially, the following are equivalent:
@media all and (min-width:400px) { ... } @media (min-width:400px) { ... }
Using the shorthand syntax with Respond caused incorrect matches with the regex used for media type.
Tests:
I modified the last test in the visual test cases (test/test.css) to use shorthand syntax, and it is passing. I also added tests that expose a bug in the way Respond injects style blocks grouped by media type rather than by query expression. I'll file an issue for that one.