Module: CSSPool::CSS
- Defined in:
- lib/css_inliner/csspool.rb
Defined Under Namespace
Classes: Declaration
Class Method Summary collapse
-
.merge_declarations(base, other) ⇒ Aarray<Declaration>
Merge declarations in each argument.
-
.update_declarations(base, other) ⇒ Array<Declaration>
Update declarations in
base
with ones inother
.
Class Method Details
.merge_declarations(base, other) ⇒ Aarray<Declaration>
Merge declarations in each argument
32 33 34 |
# File 'lib/css_inliner/csspool.rb', line 32 def merge_declarations(base, other) update_declarations base.dup, other end |
.update_declarations(base, other) ⇒ Array<Declaration>
Update declarations in base
with ones in other
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/css_inliner/csspool.rb', line 10 def update_declarations(base, other) other_decls = other.map {|decl| decl..map(&:expand_dimension)}.flatten other_decls.each do |other_decl| base_decls = base.find_all {|base_decl| base_decl.property == other_decl.property} base_decls = base_decls.map {|decl| decl..map(&:expand_dimension)}.flatten if base_decls.empty? base << other_decl else base_decl = base_decls.shift base_decls.each do |decl| base_decl.update decl end base_decl.update other_decl end end base end |