Class: Opal::Rewriters::DotJsSyntax
- Defined in:
- opal/lib/opal/rewriters/dot_js_syntax.rb
Instance Method Summary collapse
- #on_send(node) ⇒ Object
- #to_js_attr_assign_call(recv, property, value) ⇒ Object
- #to_js_attr_call(recv, property) ⇒ Object
- #to_native_js_call(recv, meth, args) ⇒ Object
Methods inherited from Base
#append_to_body, #prepend_to_body, #s, s
Instance Method Details
#on_send(node) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'opal/lib/opal/rewriters/dot_js_syntax.rb', line 7 def on_send(node) recv, meth, *args = *node if recv && recv.type == :send recv_of_recv, meth_of_recv, _ = *recv if meth_of_recv == :JS case meth when :[] if args.size != 1 raise SyntaxError, ".JS[:property] syntax supports only one argument" end property = args.first node = to_js_attr_call(recv_of_recv, property) when :[]= if args.size != 2 raise SyntaxError, '.JS[:property]= syntax supports only two arguments' end property, value = *args node = to_js_attr_assign_call(recv_of_recv, property, value) else node = to_native_js_call(recv_of_recv, meth, args) end super(node) else super end else super end end |
#to_js_attr_assign_call(recv, property, value) ⇒ Object
55 56 57 |
# File 'opal/lib/opal/rewriters/dot_js_syntax.rb', line 55 def to_js_attr_assign_call(recv, property, value) s(:jsattrasgn, recv, property, value) end |
#to_js_attr_call(recv, property) ⇒ Object
48 49 50 |
# File 'opal/lib/opal/rewriters/dot_js_syntax.rb', line 48 def to_js_attr_call(recv, property) s(:jsattr, recv, property) end |
#to_native_js_call(recv, meth, args) ⇒ Object
42 43 44 |
# File 'opal/lib/opal/rewriters/dot_js_syntax.rb', line 42 def to_native_js_call(recv, meth, args) s(:jscall, recv, meth, *args) end |