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

@ -1,12 +1,12 @@
/*
* Copyright 2011 eBay Software Foundation
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -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"
}
};