ruby2js 3.5.1 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +5 -662
  3. data/lib/ruby2js.rb +61 -10
  4. data/lib/ruby2js/converter.rb +10 -4
  5. data/lib/ruby2js/converter/assign.rb +159 -0
  6. data/lib/ruby2js/converter/begin.rb +7 -2
  7. data/lib/ruby2js/converter/case.rb +7 -2
  8. data/lib/ruby2js/converter/class.rb +77 -21
  9. data/lib/ruby2js/converter/class2.rb +102 -31
  10. data/lib/ruby2js/converter/def.rb +7 -3
  11. data/lib/ruby2js/converter/dstr.rb +8 -3
  12. data/lib/ruby2js/converter/hash.rb +9 -5
  13. data/lib/ruby2js/converter/hide.rb +13 -0
  14. data/lib/ruby2js/converter/if.rb +10 -2
  15. data/lib/ruby2js/converter/import.rb +35 -4
  16. data/lib/ruby2js/converter/kwbegin.rb +9 -2
  17. data/lib/ruby2js/converter/literal.rb +14 -2
  18. data/lib/ruby2js/converter/module.rb +41 -4
  19. data/lib/ruby2js/converter/opasgn.rb +8 -0
  20. data/lib/ruby2js/converter/send.rb +45 -5
  21. data/lib/ruby2js/converter/vasgn.rb +5 -0
  22. data/lib/ruby2js/converter/xstr.rb +1 -1
  23. data/lib/ruby2js/demo.rb +53 -0
  24. data/lib/ruby2js/es2022.rb +5 -0
  25. data/lib/ruby2js/es2022/strict.rb +3 -0
  26. data/lib/ruby2js/filter.rb +9 -1
  27. data/lib/ruby2js/filter/active_functions.rb +44 -0
  28. data/lib/ruby2js/filter/camelCase.rb +4 -3
  29. data/lib/ruby2js/filter/cjs.rb +2 -0
  30. data/lib/ruby2js/filter/esm.rb +133 -7
  31. data/lib/ruby2js/filter/functions.rb +107 -98
  32. data/lib/ruby2js/filter/{wunderbar.rb → jsx.rb} +29 -7
  33. data/lib/ruby2js/filter/node.rb +95 -74
  34. data/lib/ruby2js/filter/nokogiri.rb +15 -41
  35. data/lib/ruby2js/filter/react.rb +191 -56
  36. data/lib/ruby2js/filter/require.rb +100 -5
  37. data/lib/ruby2js/filter/return.rb +15 -1
  38. data/lib/ruby2js/filter/securerandom.rb +33 -0
  39. data/lib/ruby2js/filter/stimulus.rb +185 -0
  40. data/lib/ruby2js/filter/vue.rb +9 -0
  41. data/lib/ruby2js/jsx.rb +291 -0
  42. data/lib/ruby2js/namespace.rb +75 -0
  43. data/lib/ruby2js/rails.rb +15 -9
  44. data/lib/ruby2js/serializer.rb +3 -1
  45. data/lib/ruby2js/version.rb +3 -3
  46. data/ruby2js.gemspec +1 -1
  47. metadata +14 -5
  48. data/lib/ruby2js/filter/esm_migration.rb +0 -72
  49. data/lib/ruby2js/filter/fast-deep-equal.rb +0 -23
@@ -1,17 +1,19 @@
1
1
  require 'ruby2js'
2
2
 
3
+ # Convert Wunderbar syntax to JSX
4
+
3
5
  module Ruby2JS
4
6
  module Filter
5
- module Wunderbar
7
+ module JSX
6
8
  include SEXP
7
9
 
8
10
  def on_send(node)
9
- target, method, *attrs = node.children
11
+ target, method, *args = node.children
10
12
 
11
13
  if target == s(:const, nil, :Wunderbar)
12
14
  if [:debug, :info, :warn, :error, :fatal].include? method
13
15
  method = :error if method == :fatal
14
- return node.updated(nil, [s(:const, nil, :console), method, *attrs])
16
+ return node.updated(nil, [s(:const, nil, :console), method, *args])
15
17
  end
16
18
  end
17
19
 
@@ -27,7 +29,17 @@ module Ruby2JS
27
29
  end
28
30
 
29
31
  if target == nil and method.to_s.start_with? "_"
30
- S(:xnode, *method.to_s[1..-1], *stack, *process_all(attrs))
32
+ S(:xnode, method.to_s[1..-1], *stack, *process_all(args))
33
+
34
+ elsif method == :createElement and target == s(:const, nil, :React)
35
+ if args.first.type == :str and \
36
+ (args.length == 1 or %i(nil hash).include? args[1].type)
37
+ attrs = (args[1]&.type != :nil && args[1]) || s(:hash)
38
+ S(:xnode, args[0].children.first, attrs, *process_all(args[2..-1]))
39
+ else
40
+ super
41
+ end
42
+
31
43
  else
32
44
  super
33
45
  end
@@ -42,8 +54,18 @@ module Ruby2JS
42
54
 
43
55
  if target == nil and method.to_s.start_with? "_"
44
56
  if args.children.empty?
45
- # append block as a standalone proc
46
- process send.updated(nil, [*send.children, *process_all(block)])
57
+ if method == :_
58
+ # Fragment
59
+ if send.children.length == 2
60
+ process send.updated(:xnode, ['', *process_all(block)])
61
+ else
62
+ process s(:xnode, 'React.Fragment', *send.children[2..-1],
63
+ *process_all(block))
64
+ end
65
+ else
66
+ # append block as a standalone proc
67
+ process send.updated(nil, [*send.children, *process_all(block)])
68
+ end
47
69
  else
48
70
  # iterate over Enumerable arguments if there are args present
49
71
  send = send.children
@@ -58,6 +80,6 @@ module Ruby2JS
58
80
  end
59
81
  end
60
82
 
61
- DEFAULTS.push Wunderbar
83
+ DEFAULTS.push JSX
62
84
  end
63
85
  end
@@ -1,44 +1,25 @@
1
1
  require 'ruby2js'
2
2
  require 'set'
3
3
 
4
+ Ruby2JS.module_default ||= :cjs
5
+
4
6
  module Ruby2JS
5
7
  module Filter
6
8
  module Node
7
9
  include SEXP
8
10
  extend SEXP
9
11
 
10
- CJS_SETUP = {
11
- child_process: s(:casgn, nil, :child_process,
12
- s(:send, nil, :require, s(:str, "child_process"))),
13
- fs: s(:casgn, nil, :fs, s(:send, nil, :require, s(:str, "fs"))),
14
- ARGV: s(:lvasgn, :ARGV, s(:send, s(:attr,
15
- s(:attr, nil, :process), :argv), :slice, s(:int, 2)))
16
- }
17
-
18
- ESM_SETUP = {
19
- child_process: s(:import, ['child_process'],
20
- s(:attr, nil, :child_process)),
21
- fs: s(:import, ['fs'], s(:attr, nil, :fs)),
22
- ARGV: CJS_SETUP[:ARGV]
23
- }
24
-
25
- def initialize(*args)
26
- @node_setup = nil
27
- super
28
- end
12
+ IMPORT_CHILD_PROCESS = s(:import, ['child_process'],
13
+ s(:attr, nil, :child_process))
29
14
 
30
- def process(node)
31
- return super if @node_setup
32
- @node_setup = Set.new
33
- result = super
15
+ IMPORT_FS = s(:import, ['fs'], s(:attr, nil, :fs))
34
16
 
35
- if @node_setup.empty?
36
- result
37
- else
38
- setup = @esm ? ESM_SETUP : CJS_SETUP;
39
- s(:begin, *@node_setup.to_a.map {|token| setup[token]}, result)
40
- end
41
- end
17
+ IMPORT_OS = s(:import, ['os'], s(:attr, nil, :os))
18
+
19
+ IMPORT_PATH = s(:import, ['path'], s(:attr, nil, :path))
20
+
21
+ SETUP_ARGV = s(:lvasgn, :ARGV, s(:send, s(:attr,
22
+ s(:attr, nil, :process), :argv), :slice, s(:int, 2)))
42
23
 
43
24
  def on_send(node)
44
25
  target, method, *args = node.children
@@ -51,14 +32,14 @@ module Ruby2JS
51
32
  s(:send, s(:attr, nil, :process), :exit, *process_all(args));
52
33
 
53
34
  elsif method == :system
54
- @node_setup << :child_process
35
+ prepend_list << IMPORT_CHILD_PROCESS
55
36
 
56
37
  if args.length == 1
57
- s(:send, s(:attr, nil, :child_process), :execSync,
38
+ S(:send, s(:attr, nil, :child_process), :execSync,
58
39
  process(args.first),
59
40
  s(:hash, s(:pair, s(:sym, :stdio), s(:str, 'inherit'))))
60
41
  else
61
- s(:send, s(:attr, nil, :child_process), :execFileSync,
42
+ S(:send, s(:attr, nil, :child_process), :execFileSync,
62
43
  process(args.first), s(:array, *process_all(args[1..-1])),
63
44
  s(:hash, s(:pair, s(:sym, :stdio), s(:str, 'inherit'))))
64
45
  end
@@ -79,38 +60,38 @@ module Ruby2JS
79
60
  target.type == :const and target.children.first == nil
80
61
  then
81
62
  if method == :read and args.length == 1
82
- @node_setup << :fs
83
- s(:send, s(:attr, nil, :fs), :readFileSync, *process_all(args),
63
+ prepend_list << IMPORT_FS
64
+ S(:send, s(:attr, nil, :fs), :readFileSync, *process_all(args),
84
65
  s(:str, 'utf8'))
85
66
 
86
67
  elsif method == :write and args.length == 2
87
- @node_setup << :fs
68
+ prepend_list << IMPORT_FS
88
69
  S(:send, s(:attr, nil, :fs), :writeFileSync, *process_all(args))
89
70
 
90
71
  elsif target.children.last == :IO
91
72
  super
92
73
 
93
74
  elsif [:exist?, :exists?].include? method and args.length == 1
94
- @node_setup << :fs
75
+ prepend_list << IMPORT_FS
95
76
  S(:send, s(:attr, nil, :fs), :existsSync, process(args.first))
96
77
 
97
78
  elsif method == :readlink and args.length == 1
98
- @node_setup << :fs
79
+ prepend_list << IMPORT_FS
99
80
  S(:send, s(:attr, nil, :fs), :readlinkSync, process(args.first))
100
81
 
101
82
  elsif method == :realpath and args.length == 1
102
- @node_setup << :fs
83
+ prepend_list << IMPORT_FS
103
84
  S(:send, s(:attr, nil, :fs), :realpathSync, process(args.first))
104
85
 
105
86
  elsif method == :rename and args.length == 2
106
- @node_setup << :fs
87
+ prepend_list << IMPORT_FS
107
88
  S(:send, s(:attr, nil, :fs), :renameSync, *process_all(args))
108
89
 
109
90
  elsif \
110
91
  [:chmod, :lchmod].include? method and
111
92
  args.length > 1 and args.first.type == :int
112
93
  then
113
- @node_setup << :fs
94
+ prepend_list << IMPORT_FS
114
95
 
115
96
  S(:begin, *args[1..-1].map{|file|
116
97
  S(:send, s(:attr, nil, :fs), method.to_s + 'Sync', process(file),
@@ -121,7 +102,7 @@ module Ruby2JS
121
102
  [:chown, :lchown].include? method and args.length > 2 and
122
103
  args[0].type == :int and args[1].type == :int
123
104
  then
124
- @node_setup << :fs
105
+ prepend_list << IMPORT_FS
125
106
 
126
107
  S(:begin, *args[2..-1].map{|file|
127
108
  s(:send, s(:attr, nil, :fs), method.to_s + 'Sync', process(file),
@@ -129,28 +110,51 @@ module Ruby2JS
129
110
  })
130
111
 
131
112
  elsif [:ln, :link].include? method and args.length == 2
132
- @node_setup << :fs
113
+ prepend_list << IMPORT_FS
133
114
  s(:send, s(:attr, nil, :fs), :linkSync, *process_all(args))
134
115
 
135
116
  elsif method == :symlink and args.length == 2
136
- @node_setup << :fs
137
- s(:send, s(:attr, nil, :fs), :symlinkSync, *process_all(args))
117
+ prepend_list << IMPORT_FS
118
+ S(:send, s(:attr, nil, :fs), :symlinkSync, *process_all(args))
138
119
 
139
120
  elsif method == :truncate and args.length == 2
140
- @node_setup << :fs
141
- s(:send, s(:attr, nil, :fs), :truncateSync, *process_all(args))
121
+ prepend_list << IMPORT_FS
122
+ S(:send, s(:attr, nil, :fs), :truncateSync, *process_all(args))
142
123
 
143
124
  elsif [:stat, :lstat].include? method and args.length == 1
144
- @node_setup << :fs
145
- s(:send, s(:attr, nil, :fs), method.to_s + 'Sync',
125
+ prepend_list << IMPORT_FS
126
+ S(:send, s(:attr, nil, :fs), method.to_s + 'Sync',
146
127
  process(args.first))
147
128
 
148
129
  elsif method == :unlink and args.length == 1
149
- @node_setup << :fs
130
+ prepend_list << IMPORT_FS
150
131
  S(:begin, *args.map{|file|
151
132
  S(:send, s(:attr, nil, :fs), :unlinkSync, process(file))
152
133
  })
153
134
 
135
+ elsif target.children.last == :File
136
+ if method == :absolute_path
137
+ prepend_list << IMPORT_PATH
138
+ S(:send, s(:attr, nil, :path), :resolve,
139
+ *process_all(args.reverse))
140
+ elsif method == :absolute_path?
141
+ prepend_list << IMPORT_PATH
142
+ S(:send, s(:attr, nil, :path), :isAbsolute, *process_all(args))
143
+ elsif method == :basename
144
+ prepend_list << IMPORT_PATH
145
+ S(:send, s(:attr, nil, :path), :basename, *process_all(args))
146
+ elsif method == :dirname
147
+ prepend_list << IMPORT_PATH
148
+ S(:send, s(:attr, nil, :path), :dirname, *process_all(args))
149
+ elsif method == :extname
150
+ prepend_list << IMPORT_PATH
151
+ S(:send, s(:attr, nil, :path), :extname, *process_all(args))
152
+ elsif method == :join
153
+ prepend_list << IMPORT_PATH
154
+ S(:send, s(:attr, nil, :path), :join, *process_all(args))
155
+ else
156
+ super
157
+ end
154
158
  else
155
159
  super
156
160
  end
@@ -169,15 +173,15 @@ module Ruby2JS
169
173
  end
170
174
 
171
175
  if [:cp, :copy].include? method and args.length == 2
172
- @node_setup << :fs
176
+ prepend_list << IMPORT_FS
173
177
  s(:send, s(:attr, nil, :fs), :copyFileSync, *process_all(args))
174
178
 
175
179
  elsif [:mv, :move].include? method and args.length == 2
176
- @node_setup << :fs
180
+ prepend_list << IMPORT_FS
177
181
  S(:send, s(:attr, nil, :fs), :renameSync, *process_all(args))
178
182
 
179
183
  elsif method == :mkdir and args.length == 1
180
- @node_setup << :fs
184
+ prepend_list << IMPORT_FS
181
185
  S(:begin, *list[args.last].map {|file|
182
186
  s(:send, s(:attr, nil, :fs), :mkdirSync, process(file))
183
187
  })
@@ -186,24 +190,24 @@ module Ruby2JS
186
190
  S(:send, s(:attr, nil, :process), :chdir, *process_all(args))
187
191
 
188
192
  elsif method == :pwd and args.length == 0
189
- s(:send, s(:attr, nil, :process), :cwd)
193
+ S(:send!, s(:attr, nil, :process), :cwd)
190
194
 
191
195
  elsif method == :rmdir and args.length == 1
192
- @node_setup << :fs
196
+ prepend_list << IMPORT_FS
193
197
  S(:begin, *list[args.last].map {|file|
194
198
  s(:send, s(:attr, nil, :fs), :rmdirSync, process(file))
195
199
  })
196
200
 
197
201
  elsif method == :ln and args.length == 2
198
- @node_setup << :fs
199
- s(:send, s(:attr, nil, :fs), :linkSync, *process_all(args))
202
+ prepend_list << IMPORT_FS
203
+ S(:send, s(:attr, nil, :fs), :linkSync, *process_all(args))
200
204
 
201
205
  elsif method == :ln_s and args.length == 2
202
- @node_setup << :fs
203
- s(:send, s(:attr, nil, :fs), :symlinkSync, *process_all(args))
206
+ prepend_list << IMPORT_FS
207
+ S(:send, s(:attr, nil, :fs), :symlinkSync, *process_all(args))
204
208
 
205
209
  elsif method == :rm and args.length == 1
206
- @node_setup << :fs
210
+ prepend_list << IMPORT_FS
207
211
  S(:begin, *list[args.last].map {|file|
208
212
  s(:send, s(:attr, nil, :fs), :unlinkSync, process(file))
209
213
  })
@@ -211,7 +215,7 @@ module Ruby2JS
211
215
  elsif \
212
216
  method == :chmod and args.length == 2 and args.first.type == :int
213
217
  then
214
- @node_setup << :fs
218
+ prepend_list << IMPORT_FS
215
219
 
216
220
  S(:begin, *list[args.last].map {|file|
217
221
  S(:send, s(:attr, nil, :fs), method.to_s + 'Sync', process(file),
@@ -222,14 +226,14 @@ module Ruby2JS
222
226
  method == :chown and args.length == 3 and
223
227
  args[0].type == :int and args[1].type == :int
224
228
  then
225
- @node_setup << :fs
229
+ prepend_list << IMPORT_FS
226
230
 
227
231
  S(:begin, *list[args.last].map {|file|
228
232
  s(:send, s(:attr, nil, :fs), method.to_s + 'Sync', process(file),
229
233
  *process_all(args[0..1]))})
230
234
 
231
235
  elsif method == :touch
232
- @node_setup << :fs
236
+ prepend_list << IMPORT_FS
233
237
 
234
238
  S(:begin, *list[args.first].map {|file|
235
239
  S(:send, s(:attr, nil, :fs), :closeSync,
@@ -247,18 +251,18 @@ module Ruby2JS
247
251
  if method == :chdir and args.length == 1
248
252
  S(:send, s(:attr, nil, :process), :chdir, *process_all(args))
249
253
  elsif method == :pwd and args.length == 0
250
- s(:send, s(:attr, nil, :process), :cwd)
254
+ S(:send!, s(:attr, nil, :process), :cwd)
251
255
  elsif method == :entries
252
- @node_setup << :fs
253
- s(:send, s(:attr, nil, :fs), :readdirSync, *process_all(args))
256
+ prepend_list << IMPORT_FS
257
+ S(:send, s(:attr, nil, :fs), :readdirSync, *process_all(args))
254
258
  elsif method == :mkdir and args.length == 1
255
- @node_setup << :fs
256
- s(:send, s(:attr, nil, :fs), :mkdirSync, process(args.first))
259
+ prepend_list << IMPORT_FS
260
+ S(:send, s(:attr, nil, :fs), :mkdirSync, process(args.first))
257
261
  elsif method == :rmdir and args.length == 1
258
- @node_setup << :fs
259
- s(:send, s(:attr, nil, :fs), :rmdirSync, process(args.first))
262
+ prepend_list << IMPORT_FS
263
+ S(:send, s(:attr, nil, :fs), :rmdirSync, process(args.first))
260
264
  elsif method == :mktmpdir and args.length <=1
261
- @node_setup << :fs
265
+ prepend_list << IMPORT_FS
262
266
  if args.length == 0
263
267
  prefix = s(:str, 'd')
264
268
  elsif args.first.type == :array
@@ -267,7 +271,14 @@ module Ruby2JS
267
271
  prefix = args.first
268
272
  end
269
273
 
270
- s(:send, s(:attr, nil, :fs), :mkdtempSync, process(prefix))
274
+ S(:send, s(:attr, nil, :fs), :mkdtempSync, process(prefix))
275
+ elsif method == :home and args.length == 0
276
+ prepend_list << IMPORT_OS
277
+ S(:send!, s(:attr, nil, :os), :homedir)
278
+ elsif method == :tmpdir and args.length == 0
279
+ prepend_list << IMPORT_OS
280
+ S(:send!, s(:attr, nil, :os), :tmpdir)
281
+
271
282
  else
272
283
  super
273
284
  end
@@ -298,7 +309,7 @@ module Ruby2JS
298
309
 
299
310
  def on_const(node)
300
311
  if node.children == [nil, :ARGV]
301
- @node_setup << :ARGV
312
+ prepend_list << SETUP_ARGV
302
313
  super
303
314
  elsif node.children == [nil, :ENV]
304
315
  S(:attr, s(:attr, nil, :process), :env)
@@ -308,6 +319,16 @@ module Ruby2JS
308
319
  S(:attr, s(:attr, nil, :process), :stdout)
309
320
  elsif node.children == [nil, :STDERR]
310
321
  S(:attr, s(:attr, nil, :process), :stderr)
322
+ elsif node.children.first == s(:const, nil, :File)
323
+ if node.children.last == :SEPARATOR
324
+ prepend_list << IMPORT_PATH
325
+ S(:attr, s(:attr, nil, :path), :sep)
326
+ elsif node.children.last == :PATH_SEPARATOR
327
+ prepend_list << IMPORT_PATH
328
+ S(:attr, s(:attr, nil, :path), :delimiter)
329
+ else
330
+ super
331
+ end
311
332
  else
312
333
  super
313
334
  end
@@ -326,7 +347,7 @@ module Ruby2JS
326
347
  end
327
348
 
328
349
  def on_xstr(node)
329
- @node_setup << :child_process
350
+ prepend_list << IMPORT_CHILD_PROCESS
330
351
 
331
352
  children = node.children.dup
332
353
  command = children.shift
@@ -7,33 +7,7 @@ module Ruby2JS
7
7
  include SEXP
8
8
  extend SEXP
9
9
 
10
- CJS_SETUP = {
11
- jsdom: s(:casgn, nil, :JSDOM,
12
- s(:attr, s(:send, nil, :require, s(:str, "jsdom")), :JSDOM))
13
- }
14
-
15
- ESM_SETUP = {
16
- jsdom: s(:import, ["jsdom"], [s(:attr, nil, :JSDOM)])
17
- }
18
-
19
- def initialize(*args)
20
- @nokogiri_setup = nil
21
- super
22
- end
23
-
24
- def process(node)
25
- return super if @nokogiri_setup
26
- @nokogiri_setup = Set.new
27
- result = super
28
-
29
- if @nokogiri_setup.empty?
30
- result
31
- else
32
- setup = @esm ? ESM_SETUP : CJS_SETUP;
33
- s(:begin,
34
- *@nokogiri_setup.to_a.map {|token| setup[token]}, result)
35
- end
36
- end
10
+ IMPORT_JSDOM = s(:import, ["jsdom"], [s(:attr, nil, :JSDOM)])
37
11
 
38
12
  def on_send(node)
39
13
  target, method, *args = node.children
@@ -55,7 +29,7 @@ module Ruby2JS
55
29
  [:HTML, :HTML5].include? method and
56
30
  target == s(:const, nil, :Nokogiri)
57
31
  then
58
- @nokogiri_setup << :jsdom
32
+ prepend_list << IMPORT_JSDOM
59
33
  S(:attr, s(:attr, s(:send, s(:const, nil, :JSDOM), :new,
60
34
  *process_all(args)), :window), :document)
61
35
 
@@ -65,7 +39,7 @@ module Ruby2JS
65
39
  target.children.first == s(:const, nil, :Nokogiri) and
66
40
  [:HTML, :HTML5].include? target.children.last
67
41
  then
68
- @nokogiri_setup << :jsdom
42
+ prepend_list << IMPORT_JSDOM
69
43
  S(:attr, s(:attr, s(:send, s(:const, nil, :JSDOM), :new,
70
44
  *process_all(args)), :window), :document)
71
45
 
@@ -73,40 +47,40 @@ module Ruby2JS
73
47
  method == :at and
74
48
  args.length == 1 and args.first.type == :str
75
49
  then
76
- S(:send, target, :querySelector, process(args.first))
50
+ S(:send, process(target), :querySelector, process(args.first))
77
51
 
78
52
  elsif \
79
53
  method == :search and
80
54
  args.length == 1 and args.first.type == :str
81
55
  then
82
- S(:send, target, :querySelectorAll, process(args.first))
56
+ S(:send, process(target), :querySelectorAll, process(args.first))
83
57
 
84
58
  elsif method === :parent and args.length == 0
85
- S(:attr, target, :parentNode)
59
+ S(:attr, process(target), :parentNode)
86
60
 
87
61
  elsif method === :name and args.length == 0
88
- S(:attr, target, :nodeName)
62
+ S(:attr, process(target), :nodeName)
89
63
 
90
64
  elsif [:text, :content].include? method and args.length == 0
91
- S(:attr, target, :textContent)
65
+ S(:attr, process(target), :textContent)
92
66
 
93
67
  elsif method == :content= and args.length == 1
94
- S(:send, target, :textContent=, *process_all(args))
68
+ S(:send, process(target), :textContent=, *process_all(args))
95
69
 
96
70
  elsif method === :inner_html and args.length == 0
97
- S(:attr, target, :innerHTML)
71
+ S(:attr, process(target), :innerHTML)
98
72
 
99
73
  elsif method == :inner_html= and args.length == 1
100
- S(:send, target, :innerHTML=, *process_all(args))
74
+ S(:send, process(target), :innerHTML=, *process_all(args))
101
75
 
102
76
  elsif method === :to_html and args.length == 0
103
- S(:attr, target, :outerHTML)
77
+ S(:attr, process(target), :outerHTML)
104
78
 
105
79
  elsif \
106
80
  [:attr, :get_attribute].include? method and
107
81
  args.length == 1 and args.first.type == :str
108
82
  then
109
- S(:send, target, :getAttribute, process(args.first))
83
+ S(:send, process(target), :getAttribute, process(args.first))
110
84
 
111
85
  elsif \
112
86
  [:key?, :has_attribute].include? method and
@@ -180,14 +154,14 @@ module Ruby2JS
180
154
  [:add_next_sibling, :next=, :after].include? method and
181
155
  args.length == 1
182
156
  then
183
- S(:send, s(:attr, target, :parentNode), :insertBefore,
157
+ S(:send, s(:attr, process(target), :parentNode), :insertBefore,
184
158
  process(args.first), s(:attr, target, :nextSibling))
185
159
 
186
160
  elsif \
187
161
  [:add_previous_sibling, :previous=, :before].include? method and
188
162
  args.length == 1
189
163
  then
190
- S(:send, s(:attr, target, :parentNode), :insertBefore,
164
+ S(:send, s(:attr, process(target), :parentNode), :insertBefore,
191
165
  process(args.first), target)
192
166
 
193
167
  elsif method == :prepend_child and args.length == 1