Thanks to visit codestin.com
Credit goes to github.com

Skip to content

How to safely forward vnode.attrs to other vnodes? #3012

Answered by dead-claudia
mondolirondo asked this question in Q&A
Discussion options

You must be logged in to vote

If that's the case, I was wondering if it would be safe to remove them before forwarding the attrs object (as well as any attribute defined and used only by the component itself).

@mondolirondo You're looking for https://mithril.js.org/censor.html, which does exactly that. It also covers a couple bases you missed:

  • It also drops attrs.key, so it won't muck with fragments. You probably don't want stuff like [m("a", m.censor(attrs)), m("input[type=number")] to be seen as conditionally-keyed.
  • To improve performance, it avoids using delete, instead building the object manually and just skipping those keys.
  • If you have custom attributes (as appears the case here), you can strip those out wit…

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@mondolirondo
Comment options

@dead-claudia
Comment options

Answer selected by mondolirondo
@mondolirondo
Comment options

@dead-claudia
Comment options

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