Try to debug these 2 variables - matches and expressions.
var matches = query.trim().match(REGEX_MEDIA_QUERY),
expressions = ((matches[3] || '') + (matches[4] || '')).trim().match(/\([^\)]+\)/g),
Find out how your custom media query is parsed, split and consumed by this code. You would definitely get some pointers to proceed.