E106

Error

Syntax and structure

E106 — Script or a whole style in an attribute

onclick: and the other on* attributes are script in a string, which the content security policy refuses and nothing checks. A handler is on click { … }. style: is a value written as the element's whole inline style; a style is a style { } block, one property at a time.

What the compiler said

error[E106]: `onclick` on Button would put script in an attribute --> src/App.wf:3:20 | 3 | Button("Save", onclick: "save()") | ^^^^^^^ = help: Write the handler instead: `Button(…) { on click { … } }` = docs: https://webfluent.monzeromer.dev/errors/E106

The fix

Broken

wf

page P(path: "/", title: "T", description: "D") { Heading("Save").h1 Button("Save", onclick: "save()") }

Fixed

wf

page P(path: "/", title: "T", description: "D") { state saves = 0 action save() { saves = saves + 1 } Heading("Saved {saves} times").h1 Button("Save") { on click { save() } } }

Button("Save") { on click { save() } }.

style: is refused the same way: it would write a value as the element's whole style= attribute, which a value from data can turn into a box over the whole page or a request to anywhere. A style is a style { } block, one property at a time, where a value that reads state sets that one property and nothing else.

page P(path: "/", title: "T", description: "D") {
    state look = "color: red"
    Heading("Note").h1
    Text("Hi", style: look)
}
error[E106]: `style:` on Text would write a value as the element's whole inline style
 --> src/App.wf:4:16
  |
4 |     Text("Hi", style: look)
  |                ^^^^^
  = help: Write a style block instead: `Text(…) { style { color: {tone} } }`, one property at a time
  = docs: https://webfluent.monzeromer.dev/errors/E106

Fix: Text("Hi") { style { color: {tone} } }.

Each example is a whole program: it is all of src/App.wf in a project with no other .wf file (trying an example).

lints cannot lower it: it would ship a broken page.