spark-component 1.1.3 → 1.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4e3e0ad334927fb07eb25c2decef437583ba133adcc5ff0d9a6e6ed0e06513cf
4
- data.tar.gz: adaec489d853409d38ffbb58c1b0aee91d599f45ea64a8fe4065f77b6c34def9
3
+ metadata.gz: 55e7c87e7b78b2e073ed5d8ba8612f51fd038aa4a91902782930a5a2367d305b
4
+ data.tar.gz: b13756de2909fef4c1cdc93b1e674350c5c100c0b1109c6ba001187081f5cfd2
5
5
  SHA512:
6
- metadata.gz: 1669ffd2003ef564d045bb103a479ff210ae143635b81deccaa445f566079410659cda4463a0d5b3cb90dd0e3309184e00957d83fbf9ed2c536cd508261e98c9
7
- data.tar.gz: 6b39bb0f6c86b2c87a991cab875680930b3e4fc7296837c428e0c189de6697e244b9abc8625d2845ea892a05650a9479440fb952fc72760ef8fdd6522a96a94b
6
+ metadata.gz: 69753141da46b8361c76f0dd895ae440c123e5ece47f71a17bd9e95aa4a8c597c74a576d39c882fdcd33eb38afabd6d15a8dedab164d1bb4d1f2b8b688058da5
7
+ data.tar.gz: 1a04eab2d9d35cdb8e691173d14f5874e94ecbee3d82ae5b823dadb71c07fa1537f28909a4eda3cdbec93e4648c4d5f604f47e56ba96906255996f922fb4a06b
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ # v1.1.4 - 2020-01-28
2
+ - Fix: attrtibute_default_group now accepts booleans and normalizes keys.
3
+ - Fix: element_attribute_default now merges attributes.
4
+
1
5
  # v1.1.3 - 2020-01-15
2
6
  - Fix: Extending a component will now extend its class defined tag attributes, aria attributes, and data attributes.
3
7
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- spark-component (1.1.3)
4
+ spark-component (1.1.4)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -75,12 +75,34 @@ module Spark
75
75
  end
76
76
  end
77
77
 
78
+ # Takes attributes passed to a component or element and assigns values to other
79
+ # attributes as defined in their group.
80
+ #
81
+ # For example, with an attribute group:
82
+ # theme: {
83
+ # notice: { icon: "message", color: "blue" }
84
+ # error: { icon: "error", color: "red" }
85
+ # }
86
+ #
87
+ # If the attributes include `theme: :notice`, the icon and color attributes
88
+ # would default to "message" and "blue", but could be overriden if the user
89
+ # set values for them.
90
+ #
78
91
  def initialize_attribute_default_groups(attrs)
79
92
  self.class.attribute_default_groups.each do |group, group_options|
80
93
  # Determine what group name is set for this attribute.
94
+ # In the above example the group would be `theme` and the name
95
+ # would be the value passed for `theme`, or its default value.
96
+ #
97
+ # So `name` might be `:notice`.
81
98
  name = attrs[group] || self.class.attributes[group]
82
99
 
100
+ # Normalize name for hash lookup. to_s.to_sym converts booleans as well.
101
+ name = name.to_s.to_sym unless name.nil?
102
+
83
103
  # Get defaults to set from group name
104
+ # In the above example, if the name were `notice` this would be the hash
105
+ # `{ icon: "message", color: "blue" }`
84
106
  defaults = group_options[name]
85
107
 
86
108
  next unless defaults
@@ -95,7 +95,8 @@ module Spark
95
95
 
96
96
  # Override the default value for an element's attribute(s)
97
97
  def set_element_attribute_default(element, attrs = {})
98
- element_attribute_default[element] = attrs
98
+ element_attribute_default[element] ||= {}
99
+ element_attribute_default[element].merge!(attrs)
99
100
  end
100
101
 
101
102
  def element_attribute_default
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Spark
4
4
  module Component
5
- VERSION = "1.1.3"
5
+ VERSION = "1.1.4"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spark-component
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.3
4
+ version: 1.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandon Mathis
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-01-15 00:00:00.000000000 Z
11
+ date: 2020-01-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionview-component