Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change syntax #69

Open
DrSensor opened this issue May 30, 2023 · 0 comments
Open

Change syntax #69

DrSensor opened this issue May 30, 2023 · 0 comments
Labels
bug Something isn't working
Milestone

Comments

@DrSensor
Copy link
Owner

DrSensor commented May 30, 2023

The old syntax has quite a problem when used in site generator that still rely on XML parser 😭 (legacy of polyglot markup and XHTML5)

Here is the new syntax

<render-scope>
  <link href=module.js>

  <template shadowrootmode=closed>
    <button disabled ~ !disabled
            #ref=button
            @click=increment .value=count>
      Count: <span ~ #text=count>0</span>
    </button>
    <input inputmode=numeric type=number
           disabled ~ !disabled
           @change=set .value=count>

    <button disabled ~ !disabled #init=magic>Magic</button>
  </template>
</render-scope>
module.js
/** @this HTMLElementButton */
export function magic() {
  const text = new Text("")
  this.onclick = () => text.value += this.textContent
  this.append(text)
}

export default class {
  accessor count = 0
  increment() { this.count++ }

  /** @type HTMLElementButton */ button

  constructor() {
    let count = 10
    this.button.addEventListener("click", function() {
      console.log(count--)
      console.debug(this + "")
    })
  }
}
@DrSensor DrSensor added the bug Something isn't working label May 30, 2023
@DrSensor DrSensor added this to the 1.0.0 milestone May 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant