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

Assert key is not in Dynamic Attributes #144

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion src/virtual_elements.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,19 @@ if (process.env.NODE_ENV !== 'production') {

if (tag !== data.nodeName) {
throw new Error('Received a call to close ' + tag + ' but ' +
data.nodeName + ' was open.');
data.nodeName + ' was open.');
}
};


/**
* Makes sure that the key attribute does not appear in dynamic attributes.
* @param {!Object<string, *>} attrs
*/
var assertNoKeyInDynamicAttributes = function(attrs) {
if ('key' in attrs) {
throw new Error('The `key` attribute may not appear in the dynamic' +
'attributes');
}
};

Expand Down Expand Up @@ -177,6 +189,10 @@ var elementOpen = function(tag, key, statics, var_args) {
newAttrs[arguments[i]] = arguments[i + 1];
}

if (process.env.NODE_ENV !== 'production') {
assertNoKeyInDynamicAttributes(newAttrs);
}

for (attr in newAttrs) {
updateAttribute(node, attr, newAttrs[attr]);
}
Expand Down