diff options
| author | ruki <waruqi@gmail.com> | 2018-11-08 00:38:48 +0800 |
|---|---|---|
| committer | ruki <waruqi@gmail.com> | 2018-11-07 21:53:09 +0800 |
| commit | 26105034da4fcce7ac883c899d781f016559310d (patch) | |
| tree | c459a5dc4e3aa0972d9919033ece511ce76dd129 /node_modules/renderkid/lib/renderKid/styles/rule/MixedDeclarationSet.js | |
| parent | 2c77f00f1a7ecb6c8192f9c16d3b2001b254a107 (diff) | |
| download | xmake-docs-26105034da4fcce7ac883c899d781f016559310d.tar.gz xmake-docs-26105034da4fcce7ac883c899d781f016559310d.zip | |
switch to vuepress
Diffstat (limited to 'node_modules/renderkid/lib/renderKid/styles/rule/MixedDeclarationSet.js')
| -rw-r--r-- | node_modules/renderkid/lib/renderKid/styles/rule/MixedDeclarationSet.js | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/node_modules/renderkid/lib/renderKid/styles/rule/MixedDeclarationSet.js b/node_modules/renderkid/lib/renderKid/styles/rule/MixedDeclarationSet.js new file mode 100644 index 00000000..ceea06ed --- /dev/null +++ b/node_modules/renderkid/lib/renderKid/styles/rule/MixedDeclarationSet.js @@ -0,0 +1,78 @@ +// Generated by CoffeeScript 1.9.3 +var MixedDeclarationSet, + slice = [].slice; + +module.exports = MixedDeclarationSet = (function() { + var self; + + self = MixedDeclarationSet; + + MixedDeclarationSet.mix = function() { + var i, len, mixed, ruleSets, rules; + ruleSets = 1 <= arguments.length ? slice.call(arguments, 0) : []; + mixed = new self; + for (i = 0, len = ruleSets.length; i < len; i++) { + rules = ruleSets[i]; + mixed.mixWithList(rules); + } + return mixed; + }; + + function MixedDeclarationSet() { + this._declarations = {}; + } + + MixedDeclarationSet.prototype.mixWithList = function(rules) { + var i, len, rule; + rules.sort(function(a, b) { + return a.selector.priority > b.selector.priority; + }); + for (i = 0, len = rules.length; i < len; i++) { + rule = rules[i]; + this._mixWithRule(rule); + } + return this; + }; + + MixedDeclarationSet.prototype._mixWithRule = function(rule) { + var dec, prop, ref; + ref = rule.styles._declarations; + for (prop in ref) { + dec = ref[prop]; + this._mixWithDeclaration(dec); + } + }; + + MixedDeclarationSet.prototype._mixWithDeclaration = function(dec) { + var cur; + cur = this._declarations[dec.prop]; + if ((cur != null) && cur.important && !dec.important) { + return; + } + this._declarations[dec.prop] = dec; + }; + + MixedDeclarationSet.prototype.get = function(prop) { + if (prop == null) { + return this._declarations; + } + if (this._declarations[prop] == null) { + return null; + } + return this._declarations[prop].val; + }; + + MixedDeclarationSet.prototype.toObject = function() { + var dec, obj, prop, ref; + obj = {}; + ref = this._declarations; + for (prop in ref) { + dec = ref[prop]; + obj[prop] = dec.val; + } + return obj; + }; + + return MixedDeclarationSet; + +})(); |
