Matt-Esch / virtual-dom

A Virtual DOM and diffing algorithm
MIT License
11.65k stars 780 forks source link

throw better exception when duplicate keys are found #433

Open refractalize opened 7 years ago

refractalize commented 7 years ago

If VDOM has duplicate keys we see this error, which doesn't explain what went wrong:

Failed to execute 'insertBefore' on 'Node': parameter 1 is not of type 'Node'

This patch detects duplicate keys and throws this error instead:

duplicate vdom key: <key>, vdom: <vdom-selector>

Where key is the duplicate key, and vdom-selector is a tag#id.class representation of the node so you can find it.

refractalize commented 7 years ago

this should help with #409

coveralls commented 7 years ago

Coverage Status

Coverage increased (+0.02%) to 97.546% when pulling ad8686b2788abc5c2bde9354808c83811ac7131f on featurist:fix-duplicate-keys into 947ecf92b67d25bb693a0f625fa8e90c099887d5 on Matt-Esch:master.

coveralls commented 7 years ago

Coverage Status

Coverage increased (+0.02%) to 97.546% when pulling ad8686b2788abc5c2bde9354808c83811ac7131f on featurist:fix-duplicate-keys into 947ecf92b67d25bb693a0f625fa8e90c099887d5 on Matt-Esch:master.