diff --git a/lib/mqa.js b/lib/mqa.js index 5ca7ad0..e074399 100644 --- a/lib/mqa.js +++ b/lib/mqa.js @@ -12,6 +12,7 @@ var callbacks = {}; var unbindCallbacks = {}; var queries = {}; + var origin = location.origin || location.protocol + "//" + location.hostname + (location.port ? ":" + location.port: ""); /** * Helper to convert any array-like object to an actual Array. @@ -149,8 +150,10 @@ mqa.parse = function() { log("Parsing CSS rules"); toArray(document.styleSheets).forEach(function(sheet) { - if(sheet.cssRules === null) { - return; + var isOutsideOfDomain = sheet.href && sheet.href.indexOf("/") !== 0 && sheet.href.indexOf(origin) !== 0; + if(isOutsideOfDomain || sheet.cssRules === null) { + // ignore sheets out-of-domain or without CSS rules: + return; } toArray(sheet.cssRules).forEach(function(rule) { if (rule && rule instanceof CSSMediaRule) {