Fixes #203 - Incorrect behavior when attrs is used on a standard HTML tag with a tag def

This commit is contained in:
Patrick Steele-Idem 2016-01-12 13:52:50 -07:00
parent 86817e5572
commit 38cfacdb15
7 changed files with 30 additions and 5 deletions

View File

@ -183,5 +183,8 @@ module.exports = makeClass({
},
hasNestedTags: function() {
return this.nestedTags != null;
},
isCustomTag: function() {
return !!(this.template || this.renderer || this.nodeClass);
}
});

View File

@ -63,7 +63,7 @@ var coreAttrHandlers = [
],
[
'attrs', function(attr, node) {
if (this.tag) {
if (this.tag && this.tag.isCustomTag()) {
this.inputAttr = attr;
} else {
if (!node.addDynamicAttributes) {
@ -183,7 +183,6 @@ var coreAttrHandlers = [
],
[
'c-data', function(attr, node) {
console.log('c-data', typeof attr);
this.inputAttr = attr;
}
]

View File

@ -114,6 +114,14 @@
},
"test-circular-template-b": {
"template": "./taglib/test-circular-template-b/template.marko"
},
"script": {
"attributes": {
"*": {
"ignore": true
}
},
"transformer": "./taglib/script-nonce-transformer.js"
}
},
"<test-nested-tags-tabs>": "./taglib/test-nested-tags-tabs/marko-tag.json",

View File

@ -0,0 +1,8 @@
module.exports = function transform(node, compiler, template) {
if (node.hasAttribute('csp-nonce')) {
node.removeAttribute('csp-nonce');
node.setAttribute('nonce', template.makeExpression('"foo"'));
}
};

View File

@ -0,0 +1 @@
<script foo="bar" nonce="foo" hello="world">console.log('foo')</script>

View File

@ -0,0 +1 @@
<script foo="bar" attrs="data.myAttrs" csp-nonce>console.log('foo')</script>

View File

@ -0,0 +1,5 @@
exports.templateData = {
"myAttrs": {
"hello": "world"
}
};