Skip to content

Relaxing the strictness of the regular expression a little #143

Closed
glenveegee opened this Issue Jul 13, 2012 · 3 comments

3 participants

@glenveegee

Hi All,

I included a template css with hard-boiled media queries that failed to be recognised by respond.js

This query fails because there is whitespace preceding the colon character

@media only screen and (min-width : 1025px) {
........
}
i.e., the library expects the css syntax...
"min-width:"
not
"min-width :"

Modifying the minw and maxw match statements from

minw : thisq.match( /(min-width:[\s]([\s][0-9.]+)(px|em)[\s])/ ) && parseFloat( RegExp.$1 ) + ( RegExp.$2 || "" ),
maxw : thisq.match( /(max-width:[\s]
([\s][0-9.]+)(px|em)[\s])/ ) && parseFloat( RegExp.$1 ) + ( RegExp.$2 || "" )

to

minw : thisq.match( /(min-width\s:[\s]([\s][0-9.]+)(px|em)[\s])/ ) && parseFloat( RegExp.$1 ) + ( RegExp.$2 || "" ),
maxw : thisq.match( /(max-width\s:[\s]([\s][0-9.]+)(px|em)[\s])/ ) && parseFloat( RegExp.$1 ) + ( RegExp.$2 || "" )

could resolve this issue but I imagine the merits of relaxing the css regexp pattern would warrant some discussion.

Best regards,

Glen

@scottjehl
Owner

Nice. Looks good to me. Care to send a pull request? :)

@glenveegee
@zachleat
Collaborator

Ah, @jlembeck merged this. Thanks @glenveegee!

@zachleat zachleat closed this Dec 26, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.