Permalink
Browse files

attempt at editing the regexp to work without CSS comment tokens. Pro…

…bably too loose now, but it seems to work for basic cases...
  • Loading branch information...
1 parent 831de49 commit ee71444a5c2cc5e882cdf1aef2d71676e074c958 scottjehl committed May 24, 2011
Showing with 20 additions and 11 deletions.
  1. +1 −1 respond.src.js
  2. +14 −5 test/test.css
  3. +5 −5 test/unit/test.css
View
@@ -73,7 +73,7 @@
//find media blocks in css text, convert to style blocks
translate = function( styles, href, media ){
- var qs = styles.match( /@media ([^\{]+)\{((?!@media)[\s\S])*(?=\}[\s]*\/\*\/mediaquery\*\/)/gmi ),
+ var qs = styles.match( /@media ([^\{]+)\{((?!@media)[\s\S])*(?=\}(?![^\{]*\}))/gmi ),
ql = qs && qs.length || 0,
//try to get CSS path
href = href.substring( 0, href.lastIndexOf( "/" )),
View
@@ -32,34 +32,43 @@ a {
body {
background: green;
}
+ body {
+ background: green;
+ }
+ body {
+ background: green;
+ }
+ body {
+ background: green;
+ }
}
-/*/mediaquery*/
+
/*styles for 620px and up!*/
@media screen and (min-width: 620px), only print, projector {
body {
background: red;
}
-}/*/mediaquery*/
+}
/*styles for 800px and up!*/
@media screen and (min-width: 800px){
body {
background: blue;
}
-}/*/mediaquery*/
+}
/*styles for 1100px and up!*/
@media screen and (min-width: 1100px){
body {
background: orange;
}
-}/*/mediaquery*/
+}
/*styles for 1300px and up!*/
@media screen and (min-width: 1300px){
body {
background: navy;
}
-}/*/mediaquery*/
+}
View
@@ -20,14 +20,14 @@
#testelem {
width: 150px;
}
-}/*/mediaquery*/
+}
/*styles for 500px and under*/
@media screen and (max-width: 460px) {
#testelem {
height: 150px;
}
-}/*/mediaquery*/
+}
@@ -37,20 +37,20 @@
#testelem {
width: 250px;
}
-}/*/mediaquery*/
+}
/*styles for 760px and up */
@media only print, only screen and (min-width: 760px) {
#testelem {
width: 350px;
}
-}/*/mediaquery*/
+}
/*styles for print that shouldn't apply */
@media only print and (min-width: 800px) {
#testelem {
width: 500px;
}
-}/*/mediaquery*/
+}

0 comments on commit ee71444

Please sign in to comment.