mirror of
https://github.com/marko-js/marko.git
synced 2026-02-01 16:07:13 +00:00
fix: add support for nested tag long hand properties (#1592)
(cherry picked from commit 8f595fd493d4462f8cc2b103d8ea77e04616edea)
This commit is contained in:
parent
49a73a18c7
commit
36c501ce44
@ -288,7 +288,7 @@ class TagLoader {
|
||||
|
||||
var nestedTagName = part.substring(1, part.length - 1);
|
||||
nestedTag.name = nestedTagName;
|
||||
nestedTag.isRepeated = isNestedTagRepeated;
|
||||
nestedTag.isRepeated = nestedTag.isRepeated || isNestedTagRepeated;
|
||||
// Use the name of the attribute as the target property unless
|
||||
// this target property was explicitly provided
|
||||
nestedTag.targetProperty =
|
||||
@ -445,6 +445,17 @@ class TagLoader {
|
||||
var tag = this.tag;
|
||||
tag.type = value;
|
||||
}
|
||||
|
||||
isRepeated(value) {
|
||||
var tag = this.tag;
|
||||
tag.isRepeated = value;
|
||||
}
|
||||
|
||||
targetProperty(value) {
|
||||
var tag = this.tag;
|
||||
tag.targetProperty = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Declare a nested tag.
|
||||
*
|
||||
@ -454,7 +465,7 @@ class TagLoader {
|
||||
* "nested-tags": {
|
||||
* "tab": {
|
||||
* "target-property": "tabs",
|
||||
* "isRepeated": true
|
||||
* "is-repeated": true
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
@ -465,7 +476,7 @@ class TagLoader {
|
||||
|
||||
forEachEntry(value, (nestedTagName, nestedTagDef) => {
|
||||
var dependencyChain = this.dependencyChain.append(
|
||||
`nestedTags["${nestedTagName}]`
|
||||
`nestedTags["${nestedTagName}"]`
|
||||
);
|
||||
var nestedTag = new types.Tag(filePath);
|
||||
|
||||
|
||||
@ -0,0 +1,22 @@
|
||||
{
|
||||
"tags": {
|
||||
"longhand-tabs": {
|
||||
"nested-tags": {
|
||||
"tab": {
|
||||
"target-property": "tabs",
|
||||
"is-repeated": true,
|
||||
"attributes": {
|
||||
"label": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"attributes": {
|
||||
"orientation": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,20 @@
|
||||
var nodePath = require("path");
|
||||
|
||||
exports.check = function(taglibLoader, expect) {
|
||||
var taglib = taglibLoader.loadTaglibFromFile(
|
||||
nodePath.join(__dirname, "marko.json")
|
||||
);
|
||||
expect(taglib != null).to.equal(true);
|
||||
|
||||
expect(taglib.tags)
|
||||
.has.property("longhand-tabs")
|
||||
.with.property("nestedTags")
|
||||
.with.property("tab");
|
||||
|
||||
const tab = taglib.tags["longhand-tabs"].nestedTags.tab;
|
||||
expect(tab).has.property("isRepeated", true);
|
||||
expect(tab).has.property("targetProperty", "tabs");
|
||||
expect(tab)
|
||||
.has.property("attributes")
|
||||
.with.property("label");
|
||||
};
|
||||
Loading…
x
Reference in New Issue
Block a user