Giter Site home page Giter Site logo

hyper-element's People

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

hyper-element's Issues

Add support for event callbacks

someting like:

  setup(attachStore){
    const onStoreChange = attachStore() // No get state Fn
    onIncoming(onStoreChange)
  }
const cbs = []

// Called from outside
function messageIn(message){
  cbs.forEach(cbOnChange => cbOnChange(message))
}

function onIncoming(cbOnChange){
  cbs.push(cbOnChange)
}

Child element NOT re-drawing

Child element NOT re-drawing

class APerson extends hyperElement{
  
  onClick(){
    this.attrs.hi("Hello from "+this.attrs.name)
  } // note/helper : fucntion automatically have the element "this" bound
  
  render(Html){
    console.log("Re-draw?")
    Html`${this.attrs.name} <button onclick=${this.onClick}>Say hi! ${ this.attrs.x[0].path }</button>`
  } 
}

class UsersElem extends hyperElement{
  setup(onNext){

    const Interval = setInterval(onNext(()=> new Date()),1000)

    return () => clearInterval(Interval);
  }
  onHi(val){
    alert(val)
  }
  render(Html,time){
    console.log("Draw!")
    const yaml = [{path:"foo",data:{}}]
    Html`<a-person hi=${this.onHi} x=${yaml} name=${time+""}></a-person>`
  }
}
window.customElements.define("a-person", APerson)
window.customElements.define("users-elem", UsersElem)

customelements v2 incompatible

window.customElements.define("my-profile", class extends hyperElement {
    setup(attachStore) {
      autorun(attachStore(s));
    }// END setup

    render(Html, { names, timeString }) {
      Html`Profile: ${timeString}`
    }// END render
  }
)

results in Uncaught TypeError: Class constructor hyperElement cannot be invoked without 'new'. I don't think that the api has changed, but the registerElement is supposed to have been deprecated in march.

bug in passing complexe type - 2

In Example: Advanced attributes

This done NOT works !!

Html`<a-b></a-b><a-person  hi=${this.onHi} x=${{a:2}} name="Beckett"/>`

DOM out put -> <a-b></a-b><a-person hi="function () { [native code] }" name="Beckett" x="[object Object]">

bug in passing complexe type

In Example: Advanced attributes

This works

Html`<a-person hi=${this.onHi} name="Beckett"/>`

This works

Html`<a-person hi=${this.onHi} x=${{a:2}} name="Beckett"/>`

This done NOT works !!

Html`<a-person x=${{a:2}} name="Beckett"/>`

DOM out put -> <a-person name="Beckett" x="[object Object]">

style is not applied to custom child elemnts

Example. Text should be RED

class APerson extends hyperElement{
  
  onClick(){
    this.attrs.hi("Hello from "+this.attrs.name)
  } // note/helper : fucntion automatically have the element "this" bound
  
  render(Html){
    console.log("Re-draw?")
    Html`${this.attrs.name} <button onclick=${this.onClick}>Say hi! ${ this.attrs.x[0].path }</button>`
  } 
}

class UsersElem extends hyperElement{
  setup(onNext){

    const Interval = setInterval(onNext(()=> new Date()),1000)

    return () => clearInterval(Interval);
  }
  onHi(val){
    alert(val)
  }
  render(Html,time){
    console.log("Draw!")
    const yaml = [{path:"foo",data:{}}]
    Html``
    Html`<a-person hi=${this.onHi} x=${yaml} name=${time+""} style=${{color:"red"}}></a-person>`
  }
}
window.customElements.define("a-person", APerson)
window.customElements.define("users-elem", UsersElem)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.