rux 1.1.0 → 1.1.1

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: f8b60a8c9f9753af9e86862c0f907f726d5c853e2e7c96613d681ea36f6859ac
4
- data.tar.gz: 4ed1a4772678e181f7fa67ccdd4814e726a2731145e0c8a419261c2b40ad4f36
3
+ metadata.gz: 2bce30eb18d21630d6f5734554e7f81d24443cad2b97134127a606c2f9f0c341
4
+ data.tar.gz: 8925dcc3f10f9a21f03951c27218f17c9e6dc491a8b3c08864d5cd06650ccf07
5
5
  SHA512:
6
- metadata.gz: f70d67e41488c9dc648d4f05692813fe7b00ee86fc3ce34511ab75ad27de888578558775cb075f29b32df3876d0fbc7dfad78be43bdda5c198c52be8a05e5707
7
- data.tar.gz: c43ab2dbbeeb1ae8ec17b68cb2b24df38e167787b85004bc6085669fb5963180e7f41712f4b41a5697190e851494e575927a21ed01b3800705b721f399eb76fa
6
+ metadata.gz: fa4a8295e55aa4bc1be19afbba78f61633ed384752f85f3f19e61e1b5c8566e8ccb26a354bf679c95e671082eefdbb7b66fc7edefbaf57c8527bf66eb2b3d03a
7
+ data.tar.gz: 4ae2860e39d8ea6ec56b1c4679b4ffd4418a5fa83ba1b30ac71137938e9f66267aecdbd2ef65d4f141108df5f5a99a305b2e051bfdcc513172c7f48f0859eb96
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 1.1.1
2
+ * Don't slugify HTML attributes.
3
+ - Previously rux would emit `<div data-foo="bar">` as `<div data_foo="bar">` because it treated HTML attributes as if they were being passed as Ruby arguments, which don't allow dashes. If these arguments are passed to a component initializer, then they must be slugified, but HTML attributes shouldn't be affected.
4
+
1
5
  # 1.1.0
2
6
  * Remove newlines between elements. (@aalin, #3)
3
7
 
@@ -12,6 +12,10 @@ module Rux
12
12
  def accept(visitor)
13
13
  visitor.visit_tag(self)
14
14
  end
15
+
16
+ def component?
17
+ name.start_with?(/[A-Z]/)
18
+ end
15
19
  end
16
20
  end
17
21
  end
@@ -22,10 +22,10 @@ module Rux
22
22
 
23
23
  at = node.attrs.each_with_object([]) do |(k, v), ret|
24
24
  next if k == 'as'
25
- ret << Utils.attr_to_hash_elem(k, visit(v))
25
+ ret << Utils.attr_to_hash_elem(k, visit(v), slugify: node.component?)
26
26
  end
27
27
 
28
- if node.name.start_with?(/[A-Z]/)
28
+ if node.component?
29
29
  result << "render(#{node.name}.new"
30
30
 
31
31
  unless node.attrs.empty?
data/lib/rux/utils.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  module Rux
2
2
  module Utils
3
- def attr_to_hash_elem(key, value)
4
- key = key.gsub('-', '_')
3
+ def attr_to_hash_elem(key, value, slugify: true)
4
+ key = key.gsub('-', '_') if slugify
5
5
 
6
6
  if key =~ /\A[\w\d]+\z/
7
7
  "#{key}: #{value}"
data/lib/rux/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Rux
2
- VERSION = '1.1.0'
2
+ VERSION = '1.1.1'
3
3
  end
data/spec/parser_spec.rb CHANGED
@@ -270,4 +270,22 @@ describe Rux::Parser do
270
270
  }
271
271
  RUBY
272
272
  end
273
+
274
+ it 'slugifies ruby arguments' do
275
+ code = <<~RUX
276
+ <Hello data-foo="bar" />
277
+ RUX
278
+ expect(compile(code)).to eq(<<~RUBY.strip)
279
+ render(Hello.new(data_foo: "bar"))
280
+ RUBY
281
+ end
282
+
283
+ it 'does not slugify HTML attributes' do
284
+ code = <<~RUX
285
+ <div data-foo="bar" />
286
+ RUX
287
+ expect(compile(code)).to eq(<<~RUBY.strip)
288
+ Rux.tag("div", { :"data-foo" => "bar" })
289
+ RUBY
290
+ end
273
291
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rux
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cameron Dutro
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-12-17 00:00:00.000000000 Z
11
+ date: 2023-05-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parser
@@ -97,7 +97,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
97
97
  - !ruby/object:Gem::Version
98
98
  version: '0'
99
99
  requirements: []
100
- rubygems_version: 3.2.22
100
+ rubygems_version: 3.4.5
101
101
  signing_key:
102
102
  specification_version: 4
103
103
  summary: A jsx-inspired way to write view components.