mjml-rb 0.2.11 → 0.2.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e37a1df063fbb80fad16b364acfd5f80623edeeabab31d3abd7264b486a287d7
4
- data.tar.gz: 7added84353440e4750caf6c1c343baa50f23bdac800b5418a8432dd4f48e950
3
+ metadata.gz: b877cf70c778c4916d93167e650dd7238bc0a50044055b4784681cb9b72a2488
4
+ data.tar.gz: 642a476a1142ae386d8f6af1b05b555e46638e69cf83dfabbd8247c2c09d8f7d
5
5
  SHA512:
6
- metadata.gz: ffc75edaa21c23dedaeacd1ef032fa7ac4fa561f3719b9aa6314e8c6ac14a08419d22f2dfe2bcce699b680d47280ad2c7743595115ac01337bfc79176080c2fd
7
- data.tar.gz: 91ff2e86ed6d191d8aec6fb438de9624d99150225f0626d8b88a26d3c8ae0d4c5e29f707498a27e6841a8740e80d4a254115a6387a959cab5d98a3f94eb44d31
6
+ metadata.gz: 9da675856ef3de4e27f421c37a5a54f0b89065a13b3613000439d97493959269269d77d46416e7edb4550516b88a8b645c8847328595baa408eaac9045eaea5a
7
+ data.tar.gz: e14ef3402314fc2fbbb3b292945c5d7116340e5a14f8fe78d3f171054a25acdc43227396a00d6a12950e0492eefcfb04c7ea896618a9112f16a501ebe80b8921
@@ -367,9 +367,43 @@ module MjmlRb
367
367
  declarations.each do |property, value|
368
368
  existing[property] = value
369
369
  end
370
+ normalize_background_fallbacks!(node, existing)
370
371
  node["style"] = existing.map { |property, value| "#{property}: #{value}" }.join("; ")
371
372
  end
372
373
 
374
+ def normalize_background_fallbacks!(node, declarations)
375
+ background_color = declarations["background-color"]
376
+ return if background_color.nil? || background_color.empty?
377
+
378
+ if syncable_background?(declarations["background"])
379
+ declarations["background"] = background_color
380
+ end
381
+
382
+ return unless node.name == "td"
383
+ return unless node["bgcolor"]
384
+ return if %w[none transparent].include?(background_color.downcase)
385
+
386
+ node["bgcolor"] = background_color
387
+ end
388
+
389
+ def syncable_background?(value)
390
+ return true if value.nil? || value.empty?
391
+
392
+ normalized = value.downcase
393
+ !normalized.include?("url(") &&
394
+ !normalized.include?("gradient(") &&
395
+ !normalized.include?("/") &&
396
+ !normalized.include?(" no-repeat") &&
397
+ !normalized.include?(" repeat") &&
398
+ !normalized.include?(" fixed") &&
399
+ !normalized.include?(" scroll") &&
400
+ !normalized.include?(" center") &&
401
+ !normalized.include?(" top") &&
402
+ !normalized.include?(" bottom") &&
403
+ !normalized.include?(" left") &&
404
+ !normalized.include?(" right")
405
+ end
406
+
373
407
  def append_component_head_styles(document, context)
374
408
  component_registry.each_value.uniq.each do |component|
375
409
  next unless component.respond_to?(:head_style)
@@ -1,3 +1,3 @@
1
1
  module MjmlRb
2
- VERSION = "0.2.11".freeze
2
+ VERSION = "0.2.12".freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mjml-rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.11
4
+ version: 0.2.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrei Andriichuk