Custom Elements

28 views
Skip to first unread message

Luigi vargas aquino

unread,
Nov 23, 2016, 7:47:11 AM11/23/16
to opalrb
Hi folks!

I want to rewrite legacy Custom Elements of one of my Rails app in Opal, like this https://gist.github.com/007lva/1265b149c70428cf23704dd527fac140. I can't find any of example of how to work with native DOM elements like HTMLSpanElement. Also I would like to know which is the "idiomatic" way to do something like this:

SharedCount = Object.create(HTMLSpanElement.prototype)


Thanks!

Elia Schito

unread,
Dec 2, 2016, 5:58:31 PM12/2/16
to opalrb
Hi Luigi,

I think you can do:

require 'native'

# bridge HTMLSpanElement into opal-world, and then:
class HTMLSpanElement < `HTMLSpanElement`
end

class SharedCount < HTMLSpanElement
end

$$[:document].registerElement 'shared-count', SharedCount.JS['$$alloc']

–Elia

--
You received this message because you are subscribed to the Google Groups "opalrb" group.
To unsubscribe from this group and stop receiving emails from it, send an email to opalrb+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Luigi vargas aquino

unread,
Dec 5, 2016, 5:54:45 PM12/5/16
to opalrb
Thank you!
Reply all
Reply to author
Forward
0 new messages