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

Allow to provide custom morphAttrs function #225

Open
rosostolato opened this issue Feb 25, 2022 · 0 comments
Open

Allow to provide custom morphAttrs function #225

rosostolato opened this issue Feb 25, 2022 · 0 comments

Comments

@rosostolato
Copy link

rosostolato commented Feb 25, 2022

I'm setting some metadata as attributes on my elements and I don't want it to be rendered in the template. So the idea is to use a custom morphAttrs function to filter out undesired attributes on the check.

I believe it's easy to update, we just need to export morphAttrs and morphdomFactory on the index.js file.

-- Edit --

Or maybe we can only provide a callback function to filter the attributes of toNode. I just cloned the repo and changed this line in the morphAttrs function and it's working as I wanted.

export default function morphAttrs(fromNode, toNode) {
  var toNodeAttrs = Array.from(toNode.attributes).filter(
    attr => !attr.name.includes('on:') && attr.name !== 'key' // filter out my metadata
  )
  var attr
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant