mirror of
https://github.com/marko-js/marko.git
synced 2025-12-08 19:26:05 +00:00
Fixes #203 - Incorrect behavior when attrs is used on a standard HTML tag with a tag def
This commit is contained in:
parent
86817e5572
commit
38cfacdb15
@ -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);
|
||||
}
|
||||
});
|
||||
@ -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;
|
||||
}
|
||||
]
|
||||
|
||||
8
test/fixtures/marko-taglib.json
vendored
8
test/fixtures/marko-taglib.json
vendored
@ -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",
|
||||
|
||||
8
test/fixtures/taglib/script-nonce-transformer.js
vendored
Normal file
8
test/fixtures/taglib/script-nonce-transformer.js
vendored
Normal 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"'));
|
||||
}
|
||||
};
|
||||
1
test/fixtures/templates/script-nonce/expected.html
vendored
Normal file
1
test/fixtures/templates/script-nonce/expected.html
vendored
Normal file
@ -0,0 +1 @@
|
||||
<script foo="bar" nonce="foo" hello="world">console.log('foo')</script>
|
||||
1
test/fixtures/templates/script-nonce/template.marko
vendored
Normal file
1
test/fixtures/templates/script-nonce/template.marko
vendored
Normal file
@ -0,0 +1 @@
|
||||
<script foo="bar" attrs="data.myAttrs" csp-nonce>console.log('foo')</script>
|
||||
5
test/fixtures/templates/script-nonce/test.js
vendored
Normal file
5
test/fixtures/templates/script-nonce/test.js
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
exports.templateData = {
|
||||
"myAttrs": {
|
||||
"hello": "world"
|
||||
}
|
||||
};
|
||||
Loading…
x
Reference in New Issue
Block a user