Skip to content

After settings element text content, it won't redraw #2962

@up9cloud

Description

@up9cloud

Is there an existing issue for this?

  • I have searched the existing issues

Mithril.js Version

2.2.2

Browser and OS

Chrome latest, Ubuntu 22.04

Project

No response

Code

import m from 'mithril'

const state   = { count: 0 }

const actions = {
  increment: () => state.count += 1,
  decrement: () => state.count -= 1
}

const Counter = {
  oninit() {
    document.getElementById('r1_1').textContent = state.count
  },
  view: () => {
    return (
      <div>
        <button onclick={actions.increment}>+</button>
        <button onclick={actions.decrement}>-</button>
        <h2>Not work:</h2>
        <div>textContent:<span id="r1_1">{state.count}</span></div>
        <h2>Control group:</h2>
        <div>{state.count}</div>
      </div>
    )
  }
}

m.mount(document.getElementById("app"), {
  view: () => <Counter></Counter>
})

Steps to Reproduce

See the code

Expected Behavior

It should redraw

Observed Behavior

It didn't redraw

Context

No response

Metadata

Metadata

Assignees

Labels

Area: CoreFor anything dealing with Mithril core itselfType: GotchaFor unwanted behavior that is still correct under the given circumstances

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions