mirror of
https://github.com/marko-js/marko.git
synced 2025-12-08 19:26:05 +00:00
Fixes #339 - Tag transformers are not being applied to tags with a dynamic tag name
This commit is contained in:
parent
29de5d5a09
commit
b85b59d594
@ -290,7 +290,7 @@ class TaglibLookup {
|
||||
/*
|
||||
* Based on the type of node we have to choose how to transform it
|
||||
*/
|
||||
if (node.tagName) {
|
||||
if (node.tagName || node.tagNameExpression) {
|
||||
this.forEachTagTransformer(node, callback, thisObj);
|
||||
} else if (node instanceof Text) {
|
||||
this.forEachTextTransformer(callback, thisObj);
|
||||
@ -327,10 +327,12 @@ class TaglibLookup {
|
||||
*/
|
||||
|
||||
if (this.merged.tags) {
|
||||
if (this.merged.tags[tagName]) {
|
||||
this.merged.tags[tagName].forEachTransformer(addTransformer);
|
||||
if (tagName) {
|
||||
if (this.merged.tags[tagName]) {
|
||||
this.merged.tags[tagName].forEachTransformer(addTransformer);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (this.merged.tags['*']) {
|
||||
this.merged.tags['*'].forEachTransformer(addTransformer);
|
||||
}
|
||||
|
||||
@ -0,0 +1 @@
|
||||
<p bar="hello">Dynamic tag name</p>
|
||||
@ -0,0 +1,6 @@
|
||||
{
|
||||
"<*>": {
|
||||
"@foo": "string",
|
||||
"transformer": "./transformer.js"
|
||||
}
|
||||
}
|
||||
@ -0,0 +1 @@
|
||||
<${data.tagName} foo="abc">Dynamic tag name</>
|
||||
@ -0,0 +1,3 @@
|
||||
exports.templateData = {
|
||||
tagName: 'p'
|
||||
};
|
||||
@ -0,0 +1,4 @@
|
||||
module.exports = function transform(el, context) {
|
||||
el.removeAttribute('foo');
|
||||
el.setAttributeValue('bar', context.builder.literal('hello'));
|
||||
};
|
||||
Loading…
x
Reference in New Issue
Block a user