free_dom 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/free_dom.rb +20 -8
- metadata +1 -1
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 40cbd83a7e122bdd21f6d29050f461007647ba5c30bf82bb381fb0631e08b677
|
4
|
+
data.tar.gz: ee9de9c48dd84e74d7a2baf4606c842ffef705be469c92f227931ab6623290c6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e9355485a6b657d33a4db93477ac70d0ba6df4e85cde5bfad9aa6aa4e1b3b240f853af58d11a4bef7d1a695b4c808d1da79cfc24ff804517220a38737c5d218
|
7
|
+
data.tar.gz: 1d2c09f362b8319ad5119d0c1b66ffac47cf8a08f0563c3f9b06d939489badaa1d5ac010104712475b13505dd890d86d16e2559ab330ffa0a73ed1d2fbe0fa08
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/free_dom.rb
CHANGED
@@ -14,7 +14,18 @@ class FreeDom < Domle
|
|
14
14
|
h = {}
|
15
15
|
|
16
16
|
@doc.root.each_recursive do |e|
|
17
|
+
|
17
18
|
h[e.name.to_sym] ||= {}
|
19
|
+
|
20
|
+
# if there's a custom attribute, add a default trigger called trigger_change
|
21
|
+
a = e.attributes.keys.reject {|x| %i(id name class).include? x }
|
22
|
+
e.attributes.merge!({trigger_change: a.first}) if a.any?
|
23
|
+
|
24
|
+
# add a trigger attribute for each *on* event attribute
|
25
|
+
events = e.attributes.keys.select {|x| x =~ /^on/}\
|
26
|
+
.map {|x| 'trigger_' + x.to_s[/(?<=^on)\w+/]}
|
27
|
+
e.attributes.merge! events.zip(['']*events.length).to_h
|
28
|
+
|
18
29
|
h[e.name.to_sym].merge!(e.attributes)
|
19
30
|
end
|
20
31
|
|
@@ -26,9 +37,8 @@ class FreeDom < Domle
|
|
26
37
|
|
27
38
|
a = attributelist.keys
|
28
39
|
|
29
|
-
triggers = a.select {|x| x =~ /^trigger_/ }
|
30
|
-
|
31
|
-
attr2_accessor *(a - triggers)
|
40
|
+
triggers = a.select {|x| x =~ /^trigger_/ }
|
41
|
+
attr2_accessor *((a - triggers) + %i(onchange)).uniq
|
32
42
|
|
33
43
|
triggers.each do |x|
|
34
44
|
|
@@ -36,21 +46,22 @@ class FreeDom < Domle
|
|
36
46
|
puts 'trigger: ' + trigger.inspect if @debug
|
37
47
|
|
38
48
|
define_method(trigger) do
|
39
|
-
|
49
|
+
statement = method(('on' + trigger.to_s).to_sym).call
|
50
|
+
eval statement, $env if statement
|
40
51
|
end
|
41
52
|
|
42
|
-
if trigger == :change then
|
43
|
-
|
44
|
-
#puts 'change found'
|
53
|
+
if trigger == :change then
|
45
54
|
|
46
55
|
attribute = attributelist[x].to_sym
|
47
56
|
|
48
57
|
define_method((attribute.to_s + '=').to_sym) do |val|
|
58
|
+
|
49
59
|
oldval = attributes[attribute]
|
50
60
|
attributes[attribute] = val
|
51
|
-
|
61
|
+
|
52
62
|
@rexle.refresh if @rexle
|
53
63
|
change() unless val == oldval
|
64
|
+
|
54
65
|
val
|
55
66
|
end
|
56
67
|
|
@@ -97,3 +108,4 @@ class FreeDom < Domle
|
|
97
108
|
end
|
98
109
|
|
99
110
|
end
|
111
|
+
|
metadata
CHANGED
metadata.gz.sig
CHANGED
Binary file
|