marko 4.27.0 → 4.28.1
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/compiler/CompileContext.js +1 -0
- package/dist/compiler/ast/CustomTag.js +37 -25
- package/dist/core-tags/components/TransformHelper/convertToComponent.js +1 -1
- package/dist/node_modules/@internal/components-registry/index-browser.js +2 -0
- package/dist/runtime/helpers/dynamic-tag.js +3 -0
- package/dist/runtime/helpers/interop-require.js +3 -0
- package/dist/runtime/vdom/morphdom/index.js +12 -4
- package/dist/taglib/taglib-finder/index.js +1 -1
- package/dist/taglib/taglib-loader/Taglib.js +2 -1
- package/dist/taglib/taglib-loader/index.js +2 -2
- package/dist/taglib/taglib-loader/loadTaglibFromFile.js +2 -2
- package/dist/taglib/taglib-loader/loadTaglibFromProps.js +12 -0
- package/package.json +1 -2
- package/src/compiler/CompileContext.js +1 -0
- package/src/compiler/ast/CustomTag.js +37 -40
- package/src/core-tags/components/TransformHelper/convertToComponent.js +3 -1
- package/src/node_modules/@internal/components-define-widget-legacy/index-browser.js +2 -2
- package/src/node_modules/@internal/components-registry/index-browser.js +2 -0
- package/src/runtime/helpers/dynamic-tag.js +3 -0
- package/src/runtime/helpers/interop-require.js +3 -0
- package/src/runtime/vdom/morphdom/index.js +41 -14
- package/src/taglib/taglib-finder/index.js +1 -1
- package/src/taglib/taglib-loader/Taglib.js +2 -1
- package/src/taglib/taglib-loader/index.js +2 -2
- package/src/taglib/taglib-loader/loadTaglibFromFile.js +2 -2
- package/src/taglib/taglib-loader/loadTaglibFromProps.js +18 -0
@@ -103,6 +103,7 @@ const helpers = {
|
|
103
103
|
forIn: "marko/runtime/helpers/for-in",
|
104
104
|
forRange: "marko/runtime/helpers/for-range",
|
105
105
|
getWidgetFromOut: "marko/runtime/components/legacy/helper-getWidgetFromOut",
|
106
|
+
interopRequireDefault: "marko/runtime/helpers/interop-require",
|
106
107
|
loadNestedTag: "marko/runtime/helpers/load-nested-tag",
|
107
108
|
loadTag: "marko/runtime/helpers/load-tag",
|
108
109
|
loadTemplate: "marko/runtime/helpers/load-template",
|
@@ -480,6 +480,7 @@ class CustomTag extends HtmlElement {
|
|
480
480
|
let tagVar = codegen.addStaticVar(tagVarName, loadTag);
|
481
481
|
|
482
482
|
renderTagNode = this.generateRenderTagCode(codegen, tagVar, [inputProps, builder.identifierOut()]);
|
483
|
+
renderTagNode._isTagCall = true;
|
483
484
|
} else {
|
484
485
|
if (rendererRequirePath) {
|
485
486
|
codegen.pushMeta("tags", rendererRequirePath, true);
|
@@ -516,8 +517,10 @@ class CustomTag extends HtmlElement {
|
|
516
517
|
|
517
518
|
if (isNestedTag) {
|
518
519
|
renderTagNode = builder.functionCall(tagVar, tagArgs);
|
520
|
+
renderTagNode._isNestedTagCall = true;
|
519
521
|
} else {
|
520
522
|
renderTagNode = this.generateRenderTagCode(codegen, tagVar, tagArgs);
|
523
|
+
renderTagNode._isTagCall = true;
|
521
524
|
}
|
522
525
|
}
|
523
526
|
|
@@ -533,10 +536,22 @@ class CustomTag extends HtmlElement {
|
|
533
536
|
let renderBodyFunction;
|
534
537
|
|
535
538
|
if (hasBody) {
|
536
|
-
if (this.
|
537
|
-
const
|
538
|
-
|
539
|
-
|
539
|
+
if (this._hasDynamicNestedTags) {
|
540
|
+
const renderBody = [];
|
541
|
+
const newBody = [];
|
542
|
+
|
543
|
+
for (const child of body) {
|
544
|
+
if (hasHTML(child, context)) {
|
545
|
+
renderBody.push(child);
|
546
|
+
} else {
|
547
|
+
newBody.push(child);
|
548
|
+
}
|
549
|
+
}
|
550
|
+
|
551
|
+
if (renderBody.length) {
|
552
|
+
newBody.push(builder.returnStatement(builder.renderBodyFunction(renderBody)));
|
553
|
+
body = newBody;
|
554
|
+
}
|
540
555
|
}
|
541
556
|
|
542
557
|
if (tagDef.bodyFunction) {
|
@@ -625,27 +640,7 @@ class CustomTag extends HtmlElement {
|
|
625
640
|
return null;
|
626
641
|
} else {
|
627
642
|
this._isDirectlyNestedTag = false;
|
628
|
-
|
629
|
-
if (!parentCustomTag._hasDynamicNestedTags) {
|
630
|
-
parentCustomTag._hasDynamicNestedTags = true;
|
631
|
-
|
632
|
-
let nextBodyContent = parentCustomTag.firstChild;
|
633
|
-
let i = 0;
|
634
|
-
|
635
|
-
do {
|
636
|
-
if (nextBodyContent.type === "Text" || nextBodyContent.type === "Scriptlet" || (nextBodyContent.type === "HtmlElement" || nextBodyContent.type === "CustomTag") && !(nextBodyContent.tagDef && (nextBodyContent.tagDef.isNestedTag || nextBodyContent.tagDef.codeGeneratorModulePath))) {
|
637
|
-
parentCustomTag._mergedRenderBodyStart = i;
|
638
|
-
break;
|
639
|
-
}
|
640
|
-
|
641
|
-
nextBodyContent = nextBodyContent.nextSibling;
|
642
|
-
i++;
|
643
|
-
} while (nextBodyContent);
|
644
|
-
|
645
|
-
if (!i) {
|
646
|
-
context.addError(parentCustomTag, "Render body content must come after any dynamic nested attribute tags.");
|
647
|
-
}
|
648
|
-
}
|
643
|
+
parentCustomTag._hasDynamicNestedTags = true;
|
649
644
|
}
|
650
645
|
}
|
651
646
|
|
@@ -660,4 +655,21 @@ class CustomTag extends HtmlElement {
|
|
660
655
|
}
|
661
656
|
}
|
662
657
|
|
658
|
+
function hasHTML(node, context) {
|
659
|
+
let hasHTML = false;
|
660
|
+
const walker = context.createWalker({
|
661
|
+
enter(node) {
|
662
|
+
if (node.type === "Html" || node.type === "TextVDOM" || node._isTagCall) {
|
663
|
+
hasHTML = true;
|
664
|
+
walker.stop();
|
665
|
+
} else if (node._isNestedTagCall) {
|
666
|
+
walker.skip();
|
667
|
+
}
|
668
|
+
}
|
669
|
+
});
|
670
|
+
|
671
|
+
walker.walk(node);
|
672
|
+
return hasHTML;
|
673
|
+
}
|
674
|
+
|
663
675
|
module.exports = CustomTag;
|
@@ -94,7 +94,7 @@ module.exports = function handleComponentBind(options) {
|
|
94
94
|
if (rendererModule.inlineId) {
|
95
95
|
markoComponentVar = rendererModule.inlineId;
|
96
96
|
} else if (!isImplicitComponent) {
|
97
|
-
markoComponentVar = context.addStaticVar("marko_component", builder.require(builder.literal(rendererModule.requirePath)));
|
97
|
+
markoComponentVar = context.addStaticVar("marko_component", builder.functionCall(context.helper("interopRequireDefault"), [builder.require(builder.literal(rendererModule.requirePath))]));
|
98
98
|
}
|
99
99
|
}
|
100
100
|
|
@@ -5,6 +5,7 @@ var changeCase = require("./_change-case");
|
|
5
5
|
var ComponentsContext = require("../components/ComponentsContext");
|
6
6
|
var getComponentsContext = ComponentsContext.U_;
|
7
7
|
var ComponentDef = require("../components/ComponentDef");
|
8
|
+
var interopRequire = require("./interop-require");
|
8
9
|
var w10NOOP = require("warp10/constants").NOOP;
|
9
10
|
var RENDER_BODY_TO_JSON = function () {
|
10
11
|
return w10NOOP;
|
@@ -44,6 +45,8 @@ module.exports = function dynamicTag(out, tag, getAttrs, renderBody, args, props
|
|
44
45
|
}
|
45
46
|
}
|
46
47
|
|
48
|
+
tag = interopRequire(tag);
|
49
|
+
|
47
50
|
var renderer = tag._ || (tag.renderer ? tag.renderer.renderer || tag.renderer : tag.render);
|
48
51
|
|
49
52
|
// eslint-disable-next-line no-constant-condition
|
@@ -219,8 +219,12 @@ function morphdom(fromNode, toNode, host, componentsContext) {
|
|
219
219
|
if (!curToNodeChild.ae_) {
|
220
220
|
// We just skip over the fromNode if it is preserved
|
221
221
|
|
222
|
-
if (compareNodeNames(curToNodeChild, curVFromNodeChild)) {
|
223
|
-
|
222
|
+
if (curVFromNodeChild && curToNodeType === curVFromNodeChild.bX_ && (curToNodeType !== ELEMENT_NODE || compareNodeNames(curToNodeChild, curVFromNodeChild))) {
|
223
|
+
if (curToNodeType === ELEMENT_NODE) {
|
224
|
+
morphEl(curFromNodeChild, curVFromNodeChild, curToNodeChild, parentComponent);
|
225
|
+
} else {
|
226
|
+
morphChildren(curFromNodeChild, curToNodeChild, parentComponent);
|
227
|
+
}
|
224
228
|
} else {
|
225
229
|
// Remove the old node
|
226
230
|
detachNode(curFromNodeChild, fromNode, ownerComponent);
|
@@ -300,7 +304,7 @@ function morphdom(fromNode, toNode, host, componentsContext) {
|
|
300
304
|
if (!curToNodeChild.ae_) {
|
301
305
|
curVFromNodeChild = vElementByDOMNode.get(matchingFromEl);
|
302
306
|
|
303
|
-
if (compareNodeNames(curVFromNodeChild, curToNodeChild)) {
|
307
|
+
if (curVFromNodeChild && curToNodeType === curVFromNodeChild.bX_ && (curToNodeType !== ELEMENT_NODE || compareNodeNames(curVFromNodeChild, curToNodeChild))) {
|
304
308
|
if (fromNextSibling === matchingFromEl) {
|
305
309
|
// Single element removal:
|
306
310
|
// A <-> A
|
@@ -348,7 +352,11 @@ function morphdom(fromNode, toNode, host, componentsContext) {
|
|
348
352
|
}
|
349
353
|
}
|
350
354
|
|
351
|
-
|
355
|
+
if (curToNodeType === ELEMENT_NODE) {
|
356
|
+
morphEl(matchingFromEl, curVFromNodeChild, curToNodeChild, parentComponent);
|
357
|
+
} else {
|
358
|
+
morphChildren(matchingFromEl, curToNodeChild, parentComponent);
|
359
|
+
}
|
352
360
|
} else {
|
353
361
|
insertVirtualNodeBefore(curToNodeChild, curToNodeKey, curFromNodeChild, fromNode, ownerComponent, parentComponent);
|
354
362
|
detachNode(matchingFromEl, fromNode, ownerComponent);
|
@@ -124,7 +124,7 @@ function find(dirname, registeredTaglibs) {
|
|
124
124
|
if (!excludedPackages[name]) {
|
125
125
|
let taglibPath = resolveFrom(rootPkg.__dirname, name + "/marko.json");
|
126
126
|
if (taglibPath) {
|
127
|
-
var taglib = taglibLoader.loadTaglibFromFile(taglibPath);
|
127
|
+
var taglib = taglibLoader.loadTaglibFromFile(taglibPath, true);
|
128
128
|
helper.addTaglib(taglib);
|
129
129
|
}
|
130
130
|
}
|
@@ -28,9 +28,10 @@ function handleImport(taglib, importedTaglib) {
|
|
28
28
|
}
|
29
29
|
|
30
30
|
class Taglib {
|
31
|
-
constructor(filePath) {
|
31
|
+
constructor(filePath, isFromPackageJson) {
|
32
32
|
ok(filePath, '"filePath" expected');
|
33
33
|
this.filePath = this.path /* deprecated */ = this.id = filePath;
|
34
|
+
this.isFromPackageJson = isFromPackageJson === true;
|
34
35
|
this.dirname = path.dirname(this.filePath);
|
35
36
|
this.tags = {};
|
36
37
|
this.textTransformers = [];
|
@@ -8,8 +8,8 @@ function loadTaglibFromProps(taglib, taglibProps) {
|
|
8
8
|
return loaders.loadTaglibFromProps(taglib, taglibProps);
|
9
9
|
}
|
10
10
|
|
11
|
-
function loadTaglibFromFile(filePath) {
|
12
|
-
return loaders.loadTaglibFromFile(filePath);
|
11
|
+
function loadTaglibFromFile(filePath, isFromPackageJson) {
|
12
|
+
return loaders.loadTaglibFromFile(filePath, isFromPackageJson);
|
13
13
|
}
|
14
14
|
|
15
15
|
function loadTaglibFromDir(filePath) {
|
@@ -5,7 +5,7 @@ var loaders = require("./loaders");
|
|
5
5
|
|
6
6
|
var ok = require("assert").ok;
|
7
7
|
|
8
|
-
function loadFromFile(filePath) {
|
8
|
+
function loadFromFile(filePath, isFromPackageJson) {
|
9
9
|
ok(filePath, '"filePath" is required');
|
10
10
|
|
11
11
|
var taglib = cache.get(filePath);
|
@@ -13,7 +13,7 @@ function loadFromFile(filePath) {
|
|
13
13
|
// Only load a taglib once by caching the loaded taglibs using the file
|
14
14
|
// system file path as the key
|
15
15
|
if (!taglib) {
|
16
|
-
taglib = new types.Taglib(filePath);
|
16
|
+
taglib = new types.Taglib(filePath, isFromPackageJson);
|
17
17
|
cache.put(filePath, taglib);
|
18
18
|
|
19
19
|
var taglibProps = jsonFileReader.readFileSync(filePath);
|
@@ -221,6 +221,18 @@ class TaglibLoader {
|
|
221
221
|
}
|
222
222
|
}
|
223
223
|
|
224
|
+
exports(dir) {
|
225
|
+
var taglib = this.taglib;
|
226
|
+
var path = this.filePath;
|
227
|
+
var dirname = this.dirname;
|
228
|
+
|
229
|
+
if (taglib.isFromPackageJson) {
|
230
|
+
taglib.tagsDir = false;
|
231
|
+
|
232
|
+
scanTagsDir(path, dirname, dir, taglib, this.dependencyChain.append(`exports`));
|
233
|
+
}
|
234
|
+
}
|
235
|
+
|
224
236
|
taglibImports(imports) {
|
225
237
|
if (!resolveFrom) {
|
226
238
|
return;
|
package/package.json
CHANGED
@@ -1,10 +1,9 @@
|
|
1
1
|
{
|
2
2
|
"name": "marko",
|
3
|
-
"version": "4.
|
3
|
+
"version": "4.28.1",
|
4
4
|
"license": "MIT",
|
5
5
|
"description": "UI Components + streaming, async, high performance, HTML templating for Node.js and the browser.",
|
6
6
|
"dependencies": {
|
7
|
-
"acorn": "^7.4.0",
|
8
7
|
"app-module-path": "^2.2.0",
|
9
8
|
"argly": "^1.0.0",
|
10
9
|
"browser-refresh-client": "^1.0.0",
|
@@ -106,6 +106,7 @@ const helpers = {
|
|
106
106
|
forIn: "marko/runtime/helpers/for-in",
|
107
107
|
forRange: "marko/runtime/helpers/for-range",
|
108
108
|
getWidgetFromOut: "marko/runtime/components/legacy/helper-getWidgetFromOut",
|
109
|
+
interopRequireDefault: "marko/runtime/helpers/interop-require",
|
109
110
|
loadNestedTag: "marko/runtime/helpers/load-nested-tag",
|
110
111
|
loadTag: "marko/runtime/helpers/load-tag",
|
111
112
|
loadTemplate: "marko/runtime/helpers/load-template",
|
@@ -560,6 +560,7 @@ class CustomTag extends HtmlElement {
|
|
560
560
|
inputProps,
|
561
561
|
builder.identifierOut(),
|
562
562
|
]);
|
563
|
+
renderTagNode._isTagCall = true;
|
563
564
|
} else {
|
564
565
|
if (rendererRequirePath) {
|
565
566
|
codegen.pushMeta("tags", rendererRequirePath, true);
|
@@ -623,8 +624,10 @@ class CustomTag extends HtmlElement {
|
|
623
624
|
|
624
625
|
if (isNestedTag) {
|
625
626
|
renderTagNode = builder.functionCall(tagVar, tagArgs);
|
627
|
+
renderTagNode._isNestedTagCall = true
|
626
628
|
} else {
|
627
629
|
renderTagNode = this.generateRenderTagCode(codegen, tagVar, tagArgs);
|
630
|
+
renderTagNode._isTagCall = true;
|
628
631
|
}
|
629
632
|
}
|
630
633
|
|
@@ -640,12 +643,22 @@ class CustomTag extends HtmlElement {
|
|
640
643
|
let renderBodyFunction;
|
641
644
|
|
642
645
|
if (hasBody) {
|
643
|
-
if (this.
|
644
|
-
const
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
646
|
+
if (this._hasDynamicNestedTags) {
|
647
|
+
const renderBody = [];
|
648
|
+
const newBody = [];
|
649
|
+
|
650
|
+
for (const child of body) {
|
651
|
+
if (hasHTML(child, context)) {
|
652
|
+
renderBody.push(child);
|
653
|
+
} else {
|
654
|
+
newBody.push(child);
|
655
|
+
}
|
656
|
+
}
|
657
|
+
|
658
|
+
if (renderBody.length) {
|
659
|
+
newBody.push(builder.returnStatement(builder.renderBodyFunction(renderBody)));
|
660
|
+
body = newBody;
|
661
|
+
}
|
649
662
|
}
|
650
663
|
|
651
664
|
if (tagDef.bodyFunction) {
|
@@ -756,40 +769,7 @@ class CustomTag extends HtmlElement {
|
|
756
769
|
return null;
|
757
770
|
} else {
|
758
771
|
this._isDirectlyNestedTag = false;
|
759
|
-
|
760
|
-
if (!parentCustomTag._hasDynamicNestedTags) {
|
761
|
-
parentCustomTag._hasDynamicNestedTags = true;
|
762
|
-
|
763
|
-
let nextBodyContent = parentCustomTag.firstChild;
|
764
|
-
let i = 0;
|
765
|
-
|
766
|
-
do {
|
767
|
-
if (
|
768
|
-
nextBodyContent.type === "Text" ||
|
769
|
-
nextBodyContent.type === "Scriptlet" ||
|
770
|
-
((nextBodyContent.type === "HtmlElement" ||
|
771
|
-
nextBodyContent.type === "CustomTag") &&
|
772
|
-
!(
|
773
|
-
nextBodyContent.tagDef &&
|
774
|
-
(nextBodyContent.tagDef.isNestedTag ||
|
775
|
-
nextBodyContent.tagDef.codeGeneratorModulePath)
|
776
|
-
))
|
777
|
-
) {
|
778
|
-
parentCustomTag._mergedRenderBodyStart = i;
|
779
|
-
break;
|
780
|
-
}
|
781
|
-
|
782
|
-
nextBodyContent = nextBodyContent.nextSibling;
|
783
|
-
i++;
|
784
|
-
} while (nextBodyContent);
|
785
|
-
|
786
|
-
if (!i) {
|
787
|
-
context.addError(
|
788
|
-
parentCustomTag,
|
789
|
-
"Render body content must come after any dynamic nested attribute tags."
|
790
|
-
);
|
791
|
-
}
|
792
|
-
}
|
772
|
+
parentCustomTag._hasDynamicNestedTags = true;
|
793
773
|
}
|
794
774
|
}
|
795
775
|
|
@@ -812,4 +792,21 @@ class CustomTag extends HtmlElement {
|
|
812
792
|
}
|
813
793
|
}
|
814
794
|
|
795
|
+
function hasHTML(node, context) {
|
796
|
+
let hasHTML = false;
|
797
|
+
const walker = context.createWalker({
|
798
|
+
enter(node) {
|
799
|
+
if (node.type === "Html" || node.type === "TextVDOM" || node._isTagCall) {
|
800
|
+
hasHTML = true;
|
801
|
+
walker.stop();
|
802
|
+
} else if (node._isNestedTagCall) {
|
803
|
+
walker.skip();
|
804
|
+
}
|
805
|
+
},
|
806
|
+
});
|
807
|
+
|
808
|
+
walker.walk(node);
|
809
|
+
return hasHTML;
|
810
|
+
}
|
811
|
+
|
815
812
|
module.exports = CustomTag;
|
@@ -115,7 +115,9 @@ module.exports = function handleComponentBind(options) {
|
|
115
115
|
} else if (!isImplicitComponent) {
|
116
116
|
markoComponentVar = context.addStaticVar(
|
117
117
|
"marko_component",
|
118
|
-
builder.
|
118
|
+
builder.functionCall(context.helper("interopRequireDefault"), [
|
119
|
+
builder.require(builder.literal(rendererModule.requirePath))
|
120
|
+
])
|
119
121
|
);
|
120
122
|
}
|
121
123
|
}
|
@@ -14,7 +14,7 @@ var stateToJSONDef = {
|
|
14
14
|
return this;
|
15
15
|
}
|
16
16
|
};
|
17
|
-
function noop() {
|
17
|
+
function noop() {}
|
18
18
|
|
19
19
|
module.exports = function defineWidget(def, renderer) {
|
20
20
|
def = def.Widget || def;
|
@@ -23,7 +23,7 @@ module.exports = function defineWidget(def, renderer) {
|
|
23
23
|
return def;
|
24
24
|
}
|
25
25
|
|
26
|
-
var ComponentClass = function () {
|
26
|
+
var ComponentClass = function () {};
|
27
27
|
var proto;
|
28
28
|
var legacyInit;
|
29
29
|
|
@@ -5,6 +5,7 @@ var changeCase = require("./_change-case");
|
|
5
5
|
var ComponentsContext = require("../components/ComponentsContext");
|
6
6
|
var getComponentsContext = ComponentsContext.___getComponentsContext;
|
7
7
|
var ComponentDef = require("../components/ComponentDef");
|
8
|
+
var interopRequire = require("./interop-require");
|
8
9
|
var w10NOOP = require("warp10/constants").NOOP;
|
9
10
|
var RENDER_BODY_TO_JSON = function () {
|
10
11
|
return w10NOOP;
|
@@ -66,6 +67,8 @@ module.exports = function dynamicTag(
|
|
66
67
|
}
|
67
68
|
}
|
68
69
|
|
70
|
+
tag = interopRequire(tag);
|
71
|
+
|
69
72
|
var renderer =
|
70
73
|
tag._ ||
|
71
74
|
(tag.renderer ? tag.renderer.renderer || tag.renderer : tag.render);
|
@@ -281,13 +281,26 @@ function morphdom(fromNode, toNode, host, componentsContext) {
|
|
281
281
|
if (!curToNodeChild.___preserve) {
|
282
282
|
// We just skip over the fromNode if it is preserved
|
283
283
|
|
284
|
-
if (
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
curToNodeChild,
|
289
|
-
|
290
|
-
)
|
284
|
+
if (
|
285
|
+
curVFromNodeChild &&
|
286
|
+
curToNodeType === curVFromNodeChild.___nodeType &&
|
287
|
+
(curToNodeType !== ELEMENT_NODE ||
|
288
|
+
compareNodeNames(curToNodeChild, curVFromNodeChild))
|
289
|
+
) {
|
290
|
+
if (curToNodeType === ELEMENT_NODE) {
|
291
|
+
morphEl(
|
292
|
+
curFromNodeChild,
|
293
|
+
curVFromNodeChild,
|
294
|
+
curToNodeChild,
|
295
|
+
parentComponent,
|
296
|
+
);
|
297
|
+
} else {
|
298
|
+
morphChildren(
|
299
|
+
curFromNodeChild,
|
300
|
+
curToNodeChild,
|
301
|
+
parentComponent,
|
302
|
+
);
|
303
|
+
}
|
291
304
|
} else {
|
292
305
|
// Remove the old node
|
293
306
|
detachNode(curFromNodeChild, fromNode, ownerComponent);
|
@@ -404,7 +417,12 @@ function morphdom(fromNode, toNode, host, componentsContext) {
|
|
404
417
|
if (!curToNodeChild.___preserve) {
|
405
418
|
curVFromNodeChild = vElementByDOMNode.get(matchingFromEl);
|
406
419
|
|
407
|
-
if (
|
420
|
+
if (
|
421
|
+
curVFromNodeChild &&
|
422
|
+
curToNodeType === curVFromNodeChild.___nodeType &&
|
423
|
+
(curToNodeType !== ELEMENT_NODE ||
|
424
|
+
compareNodeNames(curVFromNodeChild, curToNodeChild))
|
425
|
+
) {
|
408
426
|
if (fromNextSibling === matchingFromEl) {
|
409
427
|
// Single element removal:
|
410
428
|
// A <-> A
|
@@ -455,12 +473,21 @@ function morphdom(fromNode, toNode, host, componentsContext) {
|
|
455
473
|
}
|
456
474
|
}
|
457
475
|
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
476
|
+
if (curToNodeType === ELEMENT_NODE) {
|
477
|
+
morphEl(
|
478
|
+
matchingFromEl,
|
479
|
+
curVFromNodeChild,
|
480
|
+
curToNodeChild,
|
481
|
+
parentComponent
|
482
|
+
);
|
483
|
+
} else {
|
484
|
+
morphChildren(
|
485
|
+
matchingFromEl,
|
486
|
+
curToNodeChild,
|
487
|
+
parentComponent,
|
488
|
+
);
|
489
|
+
}
|
490
|
+
|
464
491
|
} else {
|
465
492
|
insertVirtualNodeBefore(
|
466
493
|
curToNodeChild,
|
@@ -123,7 +123,7 @@ function find(dirname, registeredTaglibs) {
|
|
123
123
|
if (!excludedPackages[name]) {
|
124
124
|
let taglibPath = resolveFrom(rootPkg.__dirname, name + "/marko.json");
|
125
125
|
if (taglibPath) {
|
126
|
-
var taglib = taglibLoader.loadTaglibFromFile(taglibPath);
|
126
|
+
var taglib = taglibLoader.loadTaglibFromFile(taglibPath, true);
|
127
127
|
helper.addTaglib(taglib);
|
128
128
|
}
|
129
129
|
}
|
@@ -27,9 +27,10 @@ function handleImport(taglib, importedTaglib) {
|
|
27
27
|
}
|
28
28
|
|
29
29
|
class Taglib {
|
30
|
-
constructor(filePath) {
|
30
|
+
constructor(filePath, isFromPackageJson) {
|
31
31
|
ok(filePath, '"filePath" expected');
|
32
32
|
this.filePath = this.path /* deprecated */ = this.id = filePath;
|
33
|
+
this.isFromPackageJson = isFromPackageJson === true;
|
33
34
|
this.dirname = path.dirname(this.filePath);
|
34
35
|
this.tags = {};
|
35
36
|
this.textTransformers = [];
|
@@ -8,8 +8,8 @@ function loadTaglibFromProps(taglib, taglibProps) {
|
|
8
8
|
return loaders.loadTaglibFromProps(taglib, taglibProps);
|
9
9
|
}
|
10
10
|
|
11
|
-
function loadTaglibFromFile(filePath) {
|
12
|
-
return loaders.loadTaglibFromFile(filePath);
|
11
|
+
function loadTaglibFromFile(filePath, isFromPackageJson) {
|
12
|
+
return loaders.loadTaglibFromFile(filePath, isFromPackageJson);
|
13
13
|
}
|
14
14
|
|
15
15
|
function loadTaglibFromDir(filePath) {
|
@@ -5,7 +5,7 @@ var loaders = require("./loaders");
|
|
5
5
|
|
6
6
|
var ok = require("assert").ok;
|
7
7
|
|
8
|
-
function loadFromFile(filePath) {
|
8
|
+
function loadFromFile(filePath, isFromPackageJson) {
|
9
9
|
ok(filePath, '"filePath" is required');
|
10
10
|
|
11
11
|
var taglib = cache.get(filePath);
|
@@ -13,7 +13,7 @@ function loadFromFile(filePath) {
|
|
13
13
|
// Only load a taglib once by caching the loaded taglibs using the file
|
14
14
|
// system file path as the key
|
15
15
|
if (!taglib) {
|
16
|
-
taglib = new types.Taglib(filePath);
|
16
|
+
taglib = new types.Taglib(filePath, isFromPackageJson);
|
17
17
|
cache.put(filePath, taglib);
|
18
18
|
|
19
19
|
var taglibProps = jsonFileReader.readFileSync(filePath);
|
@@ -258,6 +258,24 @@ class TaglibLoader {
|
|
258
258
|
}
|
259
259
|
}
|
260
260
|
|
261
|
+
exports(dir) {
|
262
|
+
var taglib = this.taglib;
|
263
|
+
var path = this.filePath;
|
264
|
+
var dirname = this.dirname;
|
265
|
+
|
266
|
+
if (taglib.isFromPackageJson) {
|
267
|
+
taglib.tagsDir = false;
|
268
|
+
|
269
|
+
scanTagsDir(
|
270
|
+
path,
|
271
|
+
dirname,
|
272
|
+
dir,
|
273
|
+
taglib,
|
274
|
+
this.dependencyChain.append(`exports`)
|
275
|
+
);
|
276
|
+
}
|
277
|
+
}
|
278
|
+
|
261
279
|
taglibImports(imports) {
|
262
280
|
if (!resolveFrom) {
|
263
281
|
return;
|