react-style-tag
Advanced tools
Comparing version 1.0.3 to 1.0.4
@@ -54,5 +54,6 @@ 'use strict'; | ||
return _ret = (_temp = (_this = _possibleConstructorReturn(this, _Component.call.apply(_Component, [this].concat(args))), _this), _this.setPrefixedCss = function () { | ||
return _ret = (_temp = (_this = _possibleConstructorReturn(this, _Component.call.apply(_Component, [this].concat(args))), _this), _this.setStyleTag = function () { | ||
var _this$props = _this.props; | ||
var children = _this$props.children; | ||
var doNotPrefix = _this$props.doNotPrefix; | ||
var isMinified = _this$props.isMinified; | ||
@@ -66,5 +67,5 @@ | ||
var style = _this.refs.styleTag; | ||
var prefixedCss = (0, _transform.prefixCss)(children); | ||
var transformedCss = doNotPrefix ? children : (0, _transform.prefixCss)(children); | ||
style.textContent = isMinified ? (0, _transform.minify)(prefixedCss) : prefixedCss; | ||
style.textContent = isMinified ? (0, _transform.minify)(transformedCss) : transformedCss; | ||
@@ -76,17 +77,7 @@ document.head.appendChild(style); | ||
Style.prototype.componentDidMount = function componentDidMount() { | ||
var doNotPrefix = this.props.doNotPrefix; | ||
if (!doNotPrefix) { | ||
this.setPrefixedCss(); | ||
} | ||
this.setStyleTag(); | ||
}; | ||
Style.prototype.componentDidUpdate = function componentDidUpdate() { | ||
var doNotPrefix = this.props.doNotPrefix; | ||
if (!doNotPrefix) { | ||
this.setPrefixedCss(); | ||
} | ||
this.setStyleTag(); | ||
}; | ||
@@ -93,0 +84,0 @@ |
@@ -21,3 +21,3 @@ 'use strict'; | ||
/** | ||
* return the css after running through autoprefixer | ||
* return the minified string css | ||
* | ||
@@ -27,8 +27,8 @@ * @param {string} cssText | ||
*/ | ||
var prefixCss = function prefixCss(cssText) { | ||
return prefixer.process(cssText).css; | ||
var minify = function minify(cssText) { | ||
return cssText.trim().replace(/\/\*[\s\S]+?\*\//g, '').replace(/[\n\r]/g, '').replace(/\s*([:;,{}])\s*/g, '$1').replace(/\s+/g, ' ').replace(/;}/g, '}').replace(/\s+(!important)/g, '$1').replace(/#([a-fA-F0-9])\1([a-fA-F0-9])\2([a-fA-F0-9])\3(?![a-fA-F0-9])/g, '#$1$2$3').replace(/(Microsoft[^;}]*)#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])(?![a-fA-F0-9])/g, '$1#$2$2$3$3$4$4').replace(/\b(\d+[a-z]{2}) \1 \1 \1/gi, '$1').replace(/\b(\d+[a-z]{2}) (\d+[a-z]{2}) \1 \2/gi, '$1 $2').replace(/([\s|:])[0]+px/g, '$10'); | ||
}; | ||
/** | ||
* return the minified string css | ||
* return the css after running through autoprefixer | ||
* | ||
@@ -38,4 +38,4 @@ * @param {string} cssText | ||
*/ | ||
var minify = function minify(cssText) { | ||
return cssText.trim().replace(/\/\*[\s\S]+?\*\//g, '').replace(/[\n\r]/g, '').replace(/\s*([:;,{}])\s*/g, '$1').replace(/\s+/g, ' ').replace(/;}/g, '}').replace(/\s+(!important)/g, '$1').replace(/#([a-fA-F0-9])\1([a-fA-F0-9])\2([a-fA-F0-9])\3(?![a-fA-F0-9])/g, '#$1$2$3').replace(/(Microsoft[^;}]*)#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])(?![a-fA-F0-9])/g, '$1#$2$2$3$3$4$4').replace(/\b(\d+[a-z]{2}) \1 \1 \1/gi, '$1').replace(/\b(\d+[a-z]{2}) (\d+[a-z]{2}) \1 \2/gi, '$1 $2').replace(/([\s|:])[0]+px/g, '$10'); | ||
var prefixCss = function prefixCss(cssText) { | ||
return prefixer.process(cssText).css; | ||
}; | ||
@@ -42,0 +42,0 @@ |
@@ -32,3 +32,3 @@ { | ||
"webpack": "1.13.2", | ||
"webpack-dev-server": "1.14.1" | ||
"webpack-dev-server": "1.15.0" | ||
}, | ||
@@ -57,3 +57,3 @@ "homepage": "https://github.com/planttheidea/react-style-tag#readme", | ||
}, | ||
"version": "1.0.3" | ||
"version": "1.0.4" | ||
} |
13049
159