diff --git a/bower.json b/bower.json index 7d17824..dd6d8f1 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "REM-unit-polyfill", - "version": "1.1.0", + "version": "1.2.2", "homepage": "https://github.com/chuckcarpenter/REM-unit-polyfill", "authors": [ "Chuck Carpenter ", diff --git a/js/rem.js b/js/rem.js index bd3a853..d055ecb 100644 --- a/js/rem.js +++ b/js/rem.js @@ -171,13 +171,12 @@ removeComments = function ( css ) { var start = css.search(/\/\*/), end = css.search(/\*\//); - if ( (start > -1) && (end > start) ) { + while ( (start > -1) && (end > start) ) { css = css.substring(0, start) + css.substring(end + 2); - return removeComments(css); - } - else { - return css; + start = css.search(/\/\*/); + end = css.search(/\*\//); } + return css; }, // Test for Media Query support @@ -194,7 +193,7 @@ css = css.replace(/@media[\s\S]*?\}\s*\}/, ""); } - return css; + return css; }, getXMLHttpRequest = function () { // we're gonna check if our browser will let us use AJAX diff --git a/js/rem.min.js b/js/rem.min.js index 516b713..a8b9a9a 100644 --- a/js/rem.min.js +++ b/js/rem.min.js @@ -1,7 +1,7 @@ /** - * Module: rem - v1.1.0 + * Module: rem - v1.2.1 * Description: A polyfill to parse CSS links and rewrite pixel equivalents into head for non supporting browsers - * Date Built: 2014-02-26 + * Date Built: 2014-03-30 * Copyright (c) 2014 | Chuck Carpenter ,Lucas Serven ; **/ -(function(e,t){"use strict";var n=function(){var e=document.createElement("div");e.style.cssText="font-size: 1rem;";return/rem/.test(e.style.fontSize)},r=function(){var e=document.getElementsByTagName("link"),t=[];for(var n=0;n0){E=[];w=[];g=[];i()}else{u()}}},o=function(e,t){var n=c(p(e)),r=/[\w\d\s\-\/\\\[\]:,.'"*()<>+~%#^$_=|@]+\{[\w\d\s\-\/\\%#:;,.'"*()]+\d*\.?\d+rem[\w\d\s\-\/\\%#:;,.'"*()]*\}/g,i=n.match(r),s=/\d*\.?\d+rem/g,o=n.match(s),u=/(.*\/)/,a=u.exec(t)[0],f=/@import (?:url\()?['"]?([^'\)"]*)['"]?\)?[^;]*/gm,l;while((l=f.exec(e))!==null){g.push(a+l[1])}if(i!==null&&i.length!==0){y=y.concat(i);b=b.concat(o)}},u=function(){var e=/[\w\d\s\-\/\\%#:,.'"*()]+\d*\.?\d+rem[\w\d\s\-\/\\%#:,.'"*()]*[;}]/g;for(var t=0;t",r[0]);return t>4?t:e}();if(s>=7){i.onreadystatechange=function(){if(i.readyState===4){n(i,r)}}}else{i.onreadystatechange=new function(){if(i.readyState===4){n(i,r)}}}}catch(o){if(e.XDomainRequest){var u=new XDomainRequest;u.open("get",t);u.onload=function(){n(u,r)};u.onerror=function(){return false};u.send()}}},c=function(e){var t=e.search(/\/\*/),n=e.search(/\*\//);if(t>-1&&n>t){e=e.substring(0,t)+e.substring(n+2);return c(e)}else{return e}},h=function(){if(e.matchMedia||e.msMatchMedia){return true}return false},p=function(e){if(!h()){e=e.replace(/@media[\s\S]*?\}\s*\}/,"")}return e},d=function(){if(e.XMLHttpRequest){return new XMLHttpRequest}else{try{return new ActiveXObject("MSXML2.XMLHTTP")}catch(t){try{return new ActiveXObject("Microsoft.XMLHTTP")}catch(n){}}}};if(!n()){var v="",m=[],g=[],y=[],b=[],w=[],E=[],S=[],x=document.getElementsByTagName("body")[0],T="";if(x.currentStyle){if(x.currentStyle.fontSize.indexOf("px")>=0){T=x.currentStyle.fontSize.replace("px","")}else if(x.currentStyle.fontSize.indexOf("em")>=0){T=x.currentStyle.fontSize.replace("em","")}else if(x.currentStyle.fontSize.indexOf("pt")>=0){T=x.currentStyle.fontSize.replace("pt","")}else{T=x.currentStyle.fontSize.replace("%","")/100*16}}else if(e.getComputedStyle){T=document.defaultView.getComputedStyle(x,null).getPropertyValue("font-size").replace("px","")}i()}})(window) +!function(a){"use strict";var b=function(){var a=document.createElement("div");return a.style.cssText="font-size: 1rem;",/rem/.test(a.style.fontSize)},c=function(){for(var a=document.getElementsByTagName("link"),b=[],c=0;c0?(u=[],t=[],q=[],d()):g()}},f=function(a,b){for(var c,d=k(m(a)),e=/[\w\d\s\-\/\\\[\]:,.'"*()<>+~%#^$_=|@]+\{[\w\d\s\-\/\\%#:;,.'"*()]+\d*\.?\d+rem[\w\d\s\-\/\\%#:;,.'"*()]*\}/g,f=d.match(e),g=/\d*\.?\d+rem/g,h=d.match(g),i=/(.*\/)/,j=i.exec(b)[0],l=/@import (?:url\()?['"]?([^'\)"]*)['"]?\)?[^;]*/gm;null!==(c=l.exec(a));)q.push(j+c[1]);null!==f&&0!==f.length&&(r=r.concat(f),s=s.concat(h))},g=function(){for(var a=/[\w\d\s\-\/\\%#:,.'"*()]+\d*\.?\d+rem[\w\d\s\-\/\\%#:,.'"*()]*[;}]/g,b=0;b",d[0];);return b>4?b:a}();e.onreadystatechange=f>=7?function(){4===e.readyState&&c(e,d)}:new function(){4===e.readyState&&c(e,d)}}catch(g){if(a.XDomainRequest){var h=new XDomainRequest;h.open("get",b),h.onload=function(){c(h,d)},h.onerror=function(){return!1},h.send()}}},k=function(a){for(var b=a.search(/\/\*/),c=a.search(/\*\//);b>-1&&c>b;)a=a.substring(0,b)+a.substring(c+2),b=a.search(/\/\*/),c=a.search(/\*\//);return a},l=function(){return a.matchMedia||a.msMatchMedia?!0:!1},m=function(a){return l()||(a=a.replace(/@media[\s\S]*?\}\s*\}/,"")),a},n=function(){if(a.XMLHttpRequest)return new XMLHttpRequest;try{return new ActiveXObject("MSXML2.XMLHTTP")}catch(b){try{return new ActiveXObject("Microsoft.XMLHTTP")}catch(c){}}};if(!b()){var o="",p=[],q=[],r=[],s=[],t=[],u=[],v=[],w=document.getElementsByTagName("body")[0],x="";w.currentStyle?x=w.currentStyle.fontSize.indexOf("px")>=0?w.currentStyle.fontSize.replace("px",""):w.currentStyle.fontSize.indexOf("em")>=0?w.currentStyle.fontSize.replace("em",""):w.currentStyle.fontSize.indexOf("pt")>=0?w.currentStyle.fontSize.replace("pt",""):w.currentStyle.fontSize.replace("%","")/100*16:a.getComputedStyle&&(x=document.defaultView.getComputedStyle(w,null).getPropertyValue("font-size").replace("px","")),d()}}(window); \ No newline at end of file diff --git a/package.json b/package.json index 3f8027e..887d01f 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,8 @@ { "name": "rem", "description": "A polyfill to parse CSS links and rewrite pixel equivalents into head for non supporting browsers", - "main": "rem.js", - "version": "1.2.1", + "main": "js/rem.js", + "version": "1.2.2", "authors": [ "Chuck Carpenter ", "Lucas Serven "