Skip to content

Commit

Permalink
Improved the query matcher to ignore @media statements that aren't cl…
Browse files Browse the repository at this point in the history
…osed with the /*/media*/ token. This is useful for @media statements that don't need to be translated, such as those without queries, and only types (screen, print, projector, etc). This change also Fixes scottjehl#17, in which some combinations of non-tokened media queries and @font-face were causing IE to crash.
  • Loading branch information
scottjehl committed May 4, 2011
1 parent d6c476f commit c79e5d3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion respond.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions respond.src.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,15 @@

//find media blocks in css text, convert to style blocks
translate = function( styles, href, media ){
var qs = styles.match( /@media ([^\{]+)\{([\S\s]+?)(?=\}[\s]*\/\*\/mediaquery\*\/)/gmi ),
var qs = styles.match( /@media ([^\{]+)\{((?!@media)[\s\S])*(?=\}[\s]*\/\*\/mediaquery\*\/)/gmi ),
ql = qs && qs.length || 0,
//try to get CSS path
href = href.substring( 0, href.lastIndexOf( "/" )),
repUrls = function( css ){
return css.replace( /(url\()['"]?([^\/\)'"][^:\)'"]+)['"]?(\))/g, "$1" + href + "$2$3" );
},
useMedia = !ql && media;

//if path exists, tack on trailing slash
if( href.length ){ href += "/"; }

Expand Down

0 comments on commit c79e5d3

Please sign in to comment.