mirror of
https://github.com/marko-js/marko.git
synced 2025-12-08 19:26:05 +00:00
Fixes #705 - Throw error when the root HTML element has a dynamic id attribute.
This commit is contained in:
parent
fe60da9c11
commit
f73c2364d5
@ -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') {
|
||||
|
||||
@ -0,0 +1,3 @@
|
||||
$ var id = 'abc123';
|
||||
|
||||
<div id=id/>
|
||||
@ -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');
|
||||
};
|
||||
Loading…
x
Reference in New Issue
Block a user