From 1db6c104dbd88941c54f324f0ecd59e4cbb7221c Mon Sep 17 00:00:00 2001 From: Cody Schneider Date: Tue, 7 Apr 2015 09:10:45 -0400 Subject: [PATCH] Parse @imported stylesheets --- elementQuery.js | 6 ++++++ elementQuery.min.js | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/elementQuery.js b/elementQuery.js index 1776c9c..ad53637 100644 --- a/elementQuery.js +++ b/elementQuery.js @@ -164,6 +164,12 @@ processSelector(rule[cssRules][j].selectorText); } } + // Handle @imported stylesheets + else if (rule.styleSheet && rule.styleSheet.cssRules && rule.styleSheet.cssRules.length) { + for (j = 0; j < rule.styleSheet.cssRules.length; j++) { + processSelector(rule.styleSheet.cssRules[j].selectorText); + } + } else { processSelector(rule.selectorText); } diff --git a/elementQuery.min.js b/elementQuery.min.js index 1a89d87..daa98de 100644 --- a/elementQuery.min.js +++ b/elementQuery.min.js @@ -1,4 +1,4 @@ /*! elementQuery | Author: Tyson Matanich (http://matanich.com), 2013 | License: MIT */ -(function(n,t,i){"use strict";var o=n.Sizzle||jQuery.find,r={},u=null,v=function(){t.styleSheets[0]&&(u=t.styleSheets[0].cssRules!==i?"cssRules":"rules")},s=function(n,t,u,f,s){if(n=e(n),n!=""){var h;f||s||(h=/^([0-9]*.?[0-9]+)(px|em)$/.exec(u),h!=null&&(f=Number(h[1]),f+""!="NaN"&&(s=h[2]))),s&&(o.compile&&o.compile(n),r[n]===i&&(r[n]={}),r[n][t]===i&&(r[n][t]={}),r[n][t][u]=[f,s])}},y=function(n,t){var i,r,u;for(i in n)for(r in n[i])if(typeof n[i][r]=="string")s(i,r,n[i][r]);else if(typeof n[i][r]=="object")for(u=0;u0&&(o=r.indexOf(" "),o!=0&&(o>0&&(r=r.substring(0,o)),r=r.replace(/(\[(min\-width|max\-width|min\-height|max\-height)\~\=(\'|\")([0-9]*.?[0-9]+)(px|em)(\'|\")\])/gi,""),u+=r))),s(u,t[2],t[4]+t[5],h,t[5])),t[7]===i||t[7]==""?(c=t.index+t[1].length,u=null):a.lastIndex=t.index+t[1].length),l++},l=function(n,t){var r,f,e,i;if(u==null&&v(),n[u]&&n[u].length>0&&(r=n.ownerNode||n.owningElement,t||r.getAttribute("data-elementquery-bypass")===null&&r.getAttribute("data-elementquery-processed")===null)){for(f=0;f0)for(e=0;e=0;)r=r.replace(" "+u+" "," "),f=!0;f&&n.setAttribute(t,e(r))}},h=function(){for(var n=0;n0)for(h=0;h=f||i=="max-width"&&u.offsetWidth<=f||i=="min-height"&&u.offsetHeight>=f||i=="max-height"&&u.offsetHeight<=f?p(u,i,s):w(u,i,s)}!n.addEventListener&&n.attachEvent&&(l=t.documentElement.className,t.documentElement.className=" "+l,t.documentElement.className=l)};n.elementQuery=function(n,t){n&&typeof n=="object"?n.cssRules||n.rules?(l(n,!0),t==!0&&f()):y(n,t):n||t||f()},n.elementQuery.selectors=function(){var t={},n,u,f;for(n in r)for(u in r[n])for(f in r[n][u])t[n]===i&&(t[n]={}),t[n][u]===i&&(t[n][u]=[]),t[n][u][t[n][u].length]=f;return t},n.addEventListener?(n.addEventListener("resize",f,!1),n.addEventListener("DOMContentLoaded",h,!1),n.addEventListener("load",h,!1)):n.attachEvent&&(n.attachEvent("onresize",f),n.attachEvent("onload",h))})(this,document,undefined); +!function(e,t,n){"use strict";var i=e.Sizzle||jQuery.find,l={},s=null,r=function(){t.styleSheets[0]&&(s=t.styleSheets[0].cssRules!==n?"cssRules":"rules")},o=function(e,t,s,r,o){if(e=h(e),""!=e){var a;r||o||(a=/^([0-9]*.?[0-9]+)(px|em)$/.exec(s),null!=a&&(r=Number(a[1]),r+""!="NaN"&&(o=a[2]))),o&&(i.compile&&i.compile(e),l[e]===n&&(l[e]={}),l[e][t]===n&&(l[e][t]={}),l[e][t][s]=[r,o])}},a=function(e,t){var n,i,l;for(n in e)for(i in e[n])if("string"==typeof e[n][i])o(n,i,e[n][i]);else if("object"==typeof e[n][i])for(l=0;l0&&(f=u.indexOf(" "),0!=f&&(f>0&&(u=u.substring(0,f)),u=u.replace(/(\[(min\-width|max\-width|min\-height|max\-height)\~\=(\'|\")([0-9]*.?[0-9]+)(px|em)(\'|\")\])/gi,""),i+=u))),o(i,l[2],l[4]+l[5],s,l[5])),l[7]===n||""==l[7]?(r=l.index+l[1].length,i=null):h.lastIndex=l.index+l[1].length),a++}},f=function(e,t){if(null==s&&r(),e[s]&&e[s].length>0){var n=e.ownerNode||e.owningElement;if(t||null===n.getAttribute("data-elementquery-bypass")&&null===n.getAttribute("data-elementquery-processed")){var i,l,o;for(i=0;i0)for(l=0;l=0;)l=l.replace(" "+i+" "," "),s=!0;s&&e.setAttribute(t,h(l))}}},g=function(){var e;for(e=0;e0)for(s=0;s=f||"max-width"==r&&u.offsetWidth<=f||"min-height"==r&&u.offsetHeight>=f||"max-height"==r&&u.offsetHeight<=f?d(u,r,o):m(u,r,o)}if(!e.addEventListener&&e.attachEvent){var h=t.documentElement.className;t.documentElement.className=" "+h,t.documentElement.className=h}};e.elementQuery=function(e,t){e&&"object"==typeof e?e.cssRules||e.rules?(f(e,!0),1==t&&x()):a(e,t):e||t||x()},e.elementQuery.selectors=function(){var e,t,i,s={};for(e in l)for(t in l[e])for(i in l[e][t])s[e]===n&&(s[e]={}),s[e][t]===n&&(s[e][t]=[]),s[e][t][s[e][t].length]=i;return s},e.addEventListener?(e.addEventListener("resize",x,!1),e.addEventListener("DOMContentLoaded",g,!1),e.addEventListener("load",g,!1)):e.attachEvent&&(e.attachEvent("onresize",x),e.attachEvent("onload",g))}(this,document,void 0); /*! getEmPixels | Author: Tyson Matanich (http://matanich.com), 2013 | License: MIT */ (function(n,t){"use strict";var i="!important;",r="position:absolute"+i+"visibility:hidden"+i+"width:1em"+i+"font-size:1em"+i+"padding:0"+i;window.getEmPixels=function(u){var f,e,o;return u||(u=f=n.createElement("body"),f.style.cssText="font-size:1em"+i,t.insertBefore(f,n.body)),e=n.createElement("i"),e.style.cssText=r,u.appendChild(e),o=e.clientWidth,f?t.removeChild(f):u.removeChild(e),o}})(document,document.documentElement); \ No newline at end of file