Skip to content
Discussion options

You must be logged in to vote

This wouldn't work in vanilla JS, because

("button", "A button")

evaluates to "A button" because of the coma operator semantics.

We could use arrays ["button", "A button"], but it wouldn't be without problems both semantically and perf-wise. In Mithril, m('a', 'b') is a <a> virtual element, whereas ,['a', 'b'] is a fragment of two strings. So we'd need a special syntax for fragments.

The m() factory also returns objects that have a static structure, which lets the mithril core deal with it efficiently (we say it's monomorphic code, vs. polymorphic). This lets JS engines rely on the hidden class to access the various fields efficiently, making diff and render faster.

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants