ruby2js 2.1.14 → 2.1.15

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
  SHA1:
3
- metadata.gz: 7142ef3a080ba4a5342d66a8b08a99389172cb74
4
- data.tar.gz: 4cb6bb9b94504d1ba771f4605e6a886afb35e4a5
3
+ metadata.gz: 121d094f331f90e10cd459c3a1f4b22276582ff9
4
+ data.tar.gz: db0ef09b980ac15ed08e009cf3a09191c4dd32b4
5
5
  SHA512:
6
- metadata.gz: ab2b9562a0fda5be938edfd54fe713208459d4b062e38be7559571ca15af266cd5fdc5d0ca0c52a6361b5460446d3d156448e70c56d877522525e3ec900f9990
7
- data.tar.gz: d4dc3b4d5f713ff050d7f26581dbb05690a20e09eb6f02612682c4365c6ad0828e9759039ed28bafc0637a260b6198a2e277649260a7f06f8735cda3529b6389
6
+ metadata.gz: '049e26bdf2fda7434b19073fd51a931f4b7655e134f7b73167015b7a175dfd8ad6e05719d63841ef115c909872bd623475b9c774a8d271ec4d997fd74a3c37ba'
7
+ data.tar.gz: 8d4f7975ba5036f8e5b55b0db6a2ec2f4d457260451583a13d051506db8ac35acc659aec78323f7ec3a6c5d26b5a4d0b000507f85bc7c0d716fdab2c4fad2e22
@@ -610,7 +610,17 @@ module Ruby2JS
610
610
  hash['nativeOn']['input'] ||
611
611
  hash['nativeOn']['change']
612
612
 
613
- if value and value.type == :ivar
613
+ # test if value is assignable
614
+ test = value
615
+ while
616
+ test and test.type == :send and test.children.length == 2 and
617
+ test.children.last.instance_of? Symbol do
618
+ test = test.children.first
619
+ end
620
+
621
+ if value and (not test or
622
+ test.is_a? Symbol or [:ivar, :cvar].include? test.type)
623
+ then
614
624
  hash[:domProps]['value'] ||= value
615
625
  hash[:domProps]['textContent'] ||= value if tag == 'textarea'
616
626
  hash[:attrs].delete('value')
@@ -623,10 +633,20 @@ module Ruby2JS
623
633
 
624
634
  # define event handler to update ivar on input events
625
635
  if not onChange
636
+ update = s(:attr, s(:attr, s(:lvar, :event), :target), :value)
637
+
638
+ if value.type == :ivar
639
+ assign = s(:ivasgn, value.children.first, update)
640
+ elsif value.type == :cvar
641
+ assign = s(:cvasgn, value.children.first, update)
642
+ else
643
+ assign = value.updated nil, [value.children.first,
644
+ "#{value.children[1]}=", update]
645
+ end
646
+
626
647
  hash['on']['input'] ||=
627
648
  s(:block, s(:send, nil, :proc), s(:args, s(:arg, :event)),
628
- s(:ivasgn, value.children.first,
629
- s(:attr, s(:attr, s(:lvar, :event), :target), :value)))
649
+ assign)
630
650
  end
631
651
  end
632
652
 
@@ -634,7 +654,17 @@ module Ruby2JS
634
654
  # search for the presence of a 'checked' attribute
635
655
  checked = hash[:attrs]['checked']
636
656
 
637
- if checked and checked.type == :ivar
657
+ # test if value is assignable
658
+ test = checked
659
+ while
660
+ test and test.type == :send and test.children.length == 2 and
661
+ test.children.last.instance_of? Symbol do
662
+ test = test.children.first
663
+ end
664
+
665
+ if checked and (not test or
666
+ test.is_a? Symbol or [:ivar, :cvar].include? test.type)
667
+ then
638
668
  hash[:domProps]['checked'] ||= checked
639
669
  hash[:attrs].delete('checked')
640
670
 
@@ -646,10 +676,19 @@ module Ruby2JS
646
676
 
647
677
  # define event handler to update ivar on click events
648
678
  if not onChange
679
+ update = s(:send, checked, :!)
680
+
681
+ if checked.type == :ivar
682
+ assign = s(:ivasgn, checked.children.first, update)
683
+ elsif checked.type == :cvar
684
+ assign = s(:cvasgn, checked.children.first, update)
685
+ else
686
+ assign = checked.updated nil, [checked.children.first,
687
+ "#{checked.children[1]}=", update]
688
+ end
689
+
649
690
  hash['on']['click'] ||=
650
- s(:block, s(:send, nil, :proc), s(:args),
651
- s(:ivasgn,checked.children.first,
652
- s(:send, checked, :!)))
691
+ s(:block, s(:send, nil, :proc), s(:args), assign)
653
692
  end
654
693
  end
655
694
  end
@@ -2,7 +2,7 @@ module Ruby2JS
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 2
4
4
  MINOR = 1
5
- TINY = 14
5
+ TINY = 15
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
data/ruby2js.gemspec CHANGED
@@ -1,9 +1,9 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: ruby2js 2.1.14 ruby lib
2
+ # stub: ruby2js 2.1.15 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "ruby2js".freeze
6
- s.version = "2.1.14"
6
+ s.version = "2.1.15"
7
7
 
8
8
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
9
9
  s.require_paths = ["lib".freeze]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby2js
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.14
4
+ version: 2.1.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Ruby