Skip to content
This repository has been archived by the owner on Apr 29, 2021. It is now read-only.

Error on duplicate attributes #25

Closed
wants to merge 1 commit into from
Closed

Conversation

jridgewell
Copy link
Owner

This isn't directly enforced by JSX, but will cause in error in ES5 browsers. Thoughts on including it?

@jamiebuilds
Copy link
Contributor

Why would it error in ES5 environments if it gets turned into an array?

@jridgewell
Copy link
Owner Author

Re: babel/babel#2462.

It won't cause an issue with iDOM, until we release the static-hoisting feature. Then it'll cause mayhem with duplicate key attributes.

@jamiebuilds
Copy link
Contributor

I don't see how static hoisting would introduce an issue?

@jridgewell
Copy link
Owner Author

See https://github.com/babel-plugins/babel-plugin-incremental-dom/blob/hoisting/src/helpers/extract-open-arguments.js#L44-L47. If we're hoisting, and the key attribute isn't a literal (and we're not eagerly evaluating attributes), we'll push undefined instead of the key variable reference:

statics = ['id', 'id', 'key', 'key'];
// vs
statics = ['id', 'id', 'key', undefined];

If there are multiple key attributes, we'll have several undefineds in the array, and only the final key will be properly set.

@jridgewell jridgewell closed this Oct 22, 2015
@jridgewell jridgewell deleted the duplicate-attrs branch October 22, 2015 03:32
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants