Created
November 24, 2018 17:49
-
-
Save bketelsen/3fe17de697139602b2595c33edb9042e to your computer and use it in GitHub Desktop.
observed attributes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import | |
dom, jsffi, jsconsole, macros, strutils, | |
nes | |
type | |
WelcomeProps = ref object of JsObject | |
prop1: cstring | |
type StringArray = array[0..1, cstring] | |
class Welcome(HTMLElement): | |
args: varargs[JsObject] | |
constructorBody: | |
this.html = bindLit(this) | |
welcomeTempl = html_templ: | |
h1: "Hello, ${this.getAttribute('name')}" | |
h2: "This is an H2" | |
input(type="password"): "Something" | |
observedAttributes = proc(): StringArray = | |
var r: StringArray | |
r=["name","blue"] | |
result r | |
connectedCallback = proc(w: Welcome): Element = | |
w.render() | |
attributeChangedCallback = proc(name: JsObject, oldValue: JsObject, newValue: JsObject) = | |
console.log("thing") | |
render = proc(w: Welcome): Element = | |
result = tagCustomElement(w.html, w.welcomeTempl, w) | |
customElements.define("h-welcome", WelcomeConstructor) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment