Fixes #705 - Throw error when the root HTML element has a dynamic id attribute.

This commit is contained in:
Austin Kelleher 2017-05-31 13:15:15 -04:00
parent fe60da9c11
commit f73c2364d5
3 changed files with 17 additions and 1 deletions

View File

@ -199,9 +199,16 @@ module.exports = function handleRootNodes() {
hasLegacyExplicitBind = true;
} else {
if (node.hasAttribute('id')) {
let id = node.getAttributeValue('id');
if (id && id.name) {
context.addError('Root HTML element should not have a dynamic `id` attribute');
return;
}
hasIdCount++;
nodeWithAssignedId = node;
assignedId = node.getAttributeValue('id');
assignedId = id;
}
if (tagName === 'style') {

View File

@ -0,0 +1,3 @@
$ var id = 'abc123';
<div id=id/>

View File

@ -0,0 +1,6 @@
var expect = require('chai').expect;
exports.checkError = function(e) {
var message = e.toString();
expect(message).to.contain('Root HTML element should not have a dynamic `id` attribute');
};