postcss-apply
Advanced tools
Comparing version 0.6.1 to 0.7.0
@@ -11,2 +11,9 @@ # postcss-apply change Log | ||
## [0.7.0] - 2017-05-08 | ||
### Changed | ||
* PostCSS 6 upgrade. | ||
### Fixed | ||
* Polyfill `Object.entries` for node versions lower than 7. | ||
## [0.6.1] - 2017-03-10 | ||
@@ -49,3 +56,4 @@ ### Fixed | ||
[Unreleased]: https://github.com/pascalduez/postcss-apply/compare/0.6.1...HEAD | ||
[Unreleased]: https://github.com/pascalduez/postcss-apply/compare/0.7.0...HEAD | ||
[0.7.0]: https://github.com/pascalduez/postcss-apply/compare/0.6.1...0.7.0 | ||
[0.6.1]: https://github.com/pascalduez/postcss-apply/compare/0.6.0...0.6.1 | ||
@@ -52,0 +60,0 @@ [0.6.0]: https://github.com/pascalduez/postcss-apply/compare/0.5.0...0.6.0 |
@@ -7,2 +7,6 @@ 'use strict'; | ||
var _entries = require('babel-runtime/core-js/object/entries'); | ||
var _entries2 = _interopRequireDefault(_entries); | ||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
@@ -27,2 +31,3 @@ | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
/* eslint-disable no-param-reassign */ | ||
@@ -52,3 +57,3 @@ var RE_PROP_SET = /^(--)([\w-]+)(\s*)([:]?)$/; | ||
// $FlowFixMe | ||
Object.entries(sets[setName]).forEach(function (_ref) { | ||
(0, _entries2.default)(sets[setName]).forEach(function (_ref) { | ||
var _ref2 = _slicedToArray(_ref, 2), | ||
@@ -92,3 +97,3 @@ prop = _ref2[0], | ||
if (!_this.options.preserve) { | ||
rule.remove(); | ||
safeRemoveRule(rule); | ||
} | ||
@@ -105,2 +110,4 @@ | ||
_this.resolve(atRule); | ||
// @TODO honor `preserve` option. | ||
atRule.remove(); | ||
@@ -139,4 +146,7 @@ }); | ||
var newRule = _this.cache[setName].clone(); | ||
cleanIndent(newRule); | ||
if (_this.options.preserve) { | ||
parent.insertBefore(atRule, _this.cache[setName].nodes); | ||
parent.insertBefore(atRule, newRule.nodes); | ||
@@ -146,3 +156,3 @@ return; | ||
atRule.replaceWith(_this.cache[setName].nodes); | ||
atRule.replaceWith(newRule.nodes); | ||
}; | ||
@@ -185,3 +195,3 @@ | ||
/** | ||
* Helper: allow parens usage in `@apply` rule declaration. | ||
* Helper: allow parens usage in `@apply` AtRule declaration. | ||
* This is for Polymer integration. | ||
@@ -192,2 +202,25 @@ */ | ||
); | ||
} | ||
/** | ||
* Helper: remove excessive declarations indentation. | ||
*/ | ||
function cleanIndent(rule) { | ||
rule.walkDecls(function (decl) { | ||
if (typeof decl.raws.before === 'string') { | ||
decl.raws.before = decl.raws.before.replace(/[^\S\x0a\x0d]{2,}/, ' '); | ||
} | ||
}); | ||
} | ||
/** | ||
* Helper: correctly handle property sets removal and semi-colons. | ||
* @See: postcss/postcss#1014 | ||
*/ | ||
function safeRemoveRule(rule) { | ||
if (rule === rule.parent.last && rule.raws.ownSemicolon) { | ||
rule.parent.raws.semicolon = true; | ||
} | ||
rule.remove(); | ||
} |
{ | ||
"name": "postcss-apply", | ||
"version": "0.6.1", | ||
"version": "0.7.0", | ||
"description": "PostCSS plugin enabling custom properties sets references", | ||
@@ -51,21 +51,23 @@ "keywords": [ | ||
"dependencies": { | ||
"babel-runtime": "^6.23.0", | ||
"balanced-match": "^0.4.2", | ||
"postcss": "^5.2.15" | ||
"postcss": "^6.0.0" | ||
}, | ||
"devDependencies": { | ||
"babel-cli": "^6.23.0", | ||
"babel-eslint": "^7.1.1", | ||
"babel-plugin-transform-class-properties": "^6.23.0", | ||
"babel-cli": "^6.24.1", | ||
"babel-eslint": "^7.2.3", | ||
"babel-plugin-transform-class-properties": "^6.24.1", | ||
"babel-plugin-transform-object-entries": "^1.0.0", | ||
"babel-plugin-transform-object-rest-spread": "^6.23.0", | ||
"babel-preset-env": "^1.2.1", | ||
"babel-preset-env": "^1.4.0", | ||
"babel-preset-flow": "^6.23.0", | ||
"common-tags": "^1.4.0", | ||
"eslint": "^3.17.1", | ||
"eslint-config-airbnb-base": "^11.1.1", | ||
"eslint-plugin-flowtype": "^2.30.2", | ||
"eslint": "^3.19.0", | ||
"eslint-config-airbnb-base": "^11.1.3", | ||
"eslint-plugin-flowtype": "^2.32.1", | ||
"eslint-plugin-import": "^2.2.0", | ||
"eslint-plugin-jest": "^19.0.1", | ||
"flow-bin": "^0.41.0", | ||
"eslint-plugin-jest": "^20.0.0", | ||
"flow-bin": "^0.45.0", | ||
"flow-coverage-report": "^0.3.0", | ||
"jest-cli": "^19.0.2", | ||
"jest-cli": "^20.0.0", | ||
"npm-run-all": "^4.0.2", | ||
@@ -72,0 +74,0 @@ "opn-cli": "^3.1.0", |
@@ -8,3 +8,3 @@ # postcss-apply | ||
> [PostCSS] plugin enabling custom properties sets references | ||
> [PostCSS] plugin enabling custom property sets references | ||
@@ -16,2 +16,7 @@ Aka `@apply rule`. | ||
#### /!\ Heads up | ||
The `@apply` rule and custom property sets most likely won't get any real support from browser vendors and the spec is yet considered deprecated. | ||
See: | ||
* https://discourse.wicg.io/t/needed-new-champion-for-css-apply-rule/2012 | ||
* https://github.com/w3c/webcomponents/issues/300#issuecomment-276210974 | ||
@@ -18,0 +23,0 @@ ## Installation |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16000
188
150
3
20
+ Addedbabel-runtime@^6.23.0
+ Addedansi-styles@3.2.1(transitive)
+ Addedbabel-runtime@6.26.0(transitive)
+ Addedchalk@2.4.2(transitive)
+ Addedcolor-convert@1.9.3(transitive)
+ Addedcolor-name@1.1.3(transitive)
+ Addedcore-js@2.6.12(transitive)
+ Addedhas-flag@3.0.0(transitive)
+ Addedpostcss@6.0.23(transitive)
+ Addedregenerator-runtime@0.11.1(transitive)
+ Addedsource-map@0.6.1(transitive)
+ Addedsupports-color@5.5.0(transitive)
- Removedansi-regex@2.1.1(transitive)
- Removedansi-styles@2.2.1(transitive)
- Removedchalk@1.1.3(transitive)
- Removedhas-ansi@2.0.0(transitive)
- Removedhas-flag@1.0.0(transitive)
- Removedjs-base64@2.6.4(transitive)
- Removedpostcss@5.2.18(transitive)
- Removedsource-map@0.5.7(transitive)
- Removedstrip-ansi@3.0.1(transitive)
- Removedsupports-color@2.0.03.2.3(transitive)
Updatedpostcss@^6.0.0