diff --git a/css.js b/css.js
index f3061b3..9880e2f 100644
--- a/css.js
+++ b/css.js
@@ -4,21 +4,26 @@
'use strict';
var fi = function() {
+ this.skipCommentParsing = true;
this.cssImportStatements = [];
this.cssKeyframeStatements = [];
this.cssRegex = new RegExp('([\\s\\S]*?){([\\s\\S]*?)}', 'gi');
this.cssMediaQueryRegex = '((@media [\\s\\S]*?){([\\s\\S]*?}\\s*?)})';
this.cssKeyframeRegex = '((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})';
- this.combinedCSSRegex = '((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})'; //to match css & media queries together
+ this.combinedCSSRegex = '((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)(?!.*}})}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)(?![\\s\\S]?}})[\\s\\S]})'; // to match css & media queries together
this.cssCommentsRegex = '(\\/\\*[\\s\\S]*?\\*\\/)';
this.cssImportStatementRegex = new RegExp('@import .*?;', 'gi');
};
+ fi.prototype.setSkipCommentParsing = function (skip) {
+ this.skipCommentParsing = skip;
+ };
+
/*
- Strip outs css comments and returns cleaned css string
+ Strips out css comments and returns cleaned css string
- @param css, the original css string to be stipped out of comments
+ @param css, the original css string to be stripped out of comments
@return cleanedCSS contains no css comments
*/
@@ -474,6 +479,9 @@
}
for (i = 0; i < cssBase.length; i++) {
var tmp = cssBase[i];
+ if (this.skipCommentParsing) {
+ tmp.comments = undefined;
+ }
if (tmp.selector === undefined) { //temporarily omit media queries
continue;
}
diff --git a/css.min.js b/css.min.js
index 5fece1e..aa94477 100644
--- a/css.min.js
+++ b/css.min.js
@@ -1,3 +1,3 @@
-/*! css.js 27-02-2018 */
+/*! jotform-css.js 28-04-2020 */
-!function(e){"use strict";var t=function(){this.cssImportStatements=[],this.cssKeyframeStatements=[],this.cssRegex=new RegExp("([\\s\\S]*?){([\\s\\S]*?)}","gi"),this.cssMediaQueryRegex="((@media [\\s\\S]*?){([\\s\\S]*?}\\s*?)})",this.cssKeyframeRegex="((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})",this.combinedCSSRegex="((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})",this.cssCommentsRegex="(\\/\\*[\\s\\S]*?\\*\\/)",this.cssImportStatementRegex=new RegExp("@import .*?;","gi")};t.prototype.stripComments=function(e){var t=new RegExp(this.cssCommentsRegex,"gi");return e.replace(t,"")},t.prototype.parseCSS=function(e){if(void 0===e)return[];for(var t=[];;){var s=this.cssImportStatementRegex.exec(e);if(null===s)break;this.cssImportStatements.push(s[0]),t.push({selector:"@imports",type:"imports",styles:s[0]})}e=e.replace(this.cssImportStatementRegex,"");for(var r,i=new RegExp(this.cssKeyframeRegex,"gi");null!==(r=i.exec(e));)t.push({selector:"@keyframes",type:"keyframes",styles:r[0]});e=e.replace(i,"");for(var n=new RegExp(this.combinedCSSRegex,"gi");null!==(r=n.exec(e));){var o="";o=void 0===r[2]?r[5].split("\r\n").join("\n").trim():r[2].split("\r\n").join("\n").trim();var l=new RegExp(this.cssCommentsRegex,"gi"),p=l.exec(o);if(null!==p&&(o=o.replace(l,"").trim()),-1!==(o=o.replace(/\n+/,"\n")).indexOf("@media")){var a={selector:o,type:"media",subStyles:this.parseCSS(r[3]+"\n}")};null!==p&&(a.comments=p[0]),t.push(a)}else{var c={selector:o,rules:this.parseRules(r[6])};"@font-face"===o&&(c.type="font-face"),null!==p&&(c.comments=p[0]),t.push(c)}}return t},t.prototype.parseRules=function(e){var t=[];e=(e=e.split("\r\n").join("\n")).split(";");for(var s=0;s