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

Is possible to avoid setting a key when static attributes are used? #39

Open
blikblum opened this issue May 31, 2017 · 4 comments
Open

Comments

@blikblum
Copy link

The use case is:

I must patch an existing element which should be root node of render function

To do this i use idom.patchOuter

But when a key is used to create this root element idom will create another element discarding the element being patched.

See https://codepen.io/blikblum/pen/GmzVBz (to get the error behavior add a key to root div element)

@davidjamesstone
Copy link
Owner

Sorry it's taken a while to get back to you.

There doesn't seem to be a way to avoid setting a key when statics are used.

You can force a value for the key to use key` attribute to override:

<div key="foo"><div>

Could that help?

@blikblum
Copy link
Author

blikblum commented Jun 9, 2017

I need the key to be empty (no key). Tried <div key=""><div> but it still creates a random key. I can create a PR to not create key when key=""

@davidjamesstone
Copy link
Owner

I'm not sure I would want to encourage this by having the capabilty to unset a key tbh. Elements with statics but without a key can result in adjacent element getting out of sync and the idom patch doesn't work as expected.

I haven't worked with patchOuter much. Maybe I need to look into it first.

@blikblum
Copy link
Author

One possibility is not generating statics attributes when key="" or when having an specific attribute e.g. <div nostatics href="xx"><div>. Since this is opt-in would not have backward issue.

My use case is to allow create templates with the root element defined in the template body. This is a requested feature for MarionetteJS .

Technically i could implement with patchOuter but the issue outlined in first post prevents doing so.

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

2 participants