babel-plugin-essor 0.0.17 → 0.0.18-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +21 -11
- package/dist/index.js +21 -11
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1458,11 +1458,15 @@ function createPatchCall(importFn, target, attrName, value, options = {}) {
|
|
|
1458
1458
|
const { helper, name } = getPatchHelper(attrName);
|
|
1459
1459
|
const nextValue = (_a = options.nextValue) != null ? _a : value;
|
|
1460
1460
|
const isAttr = helper === "patchAttr";
|
|
1461
|
+
const emitSVGFlag = helper === "patchClass" && options.isSVG === true;
|
|
1461
1462
|
const args = isAttr ? [target, core.types.stringLiteral(name)] : [target];
|
|
1462
|
-
if (options.previousValue != null || options.includePreviousValuePlaceholder) {
|
|
1463
|
+
if (options.previousValue != null || options.includePreviousValuePlaceholder || emitSVGFlag) {
|
|
1463
1464
|
args.push((_b = options.previousValue) != null ? _b : core.types.identifier("undefined"));
|
|
1464
1465
|
}
|
|
1465
1466
|
args.push(nextValue);
|
|
1467
|
+
if (emitSVGFlag) {
|
|
1468
|
+
args.push(core.types.booleanLiteral(true));
|
|
1469
|
+
}
|
|
1466
1470
|
return core.types.callExpression(importFn(helper), args);
|
|
1467
1471
|
}
|
|
1468
1472
|
function createRefExpression(target, value) {
|
|
@@ -2724,10 +2728,10 @@ function emitElementEffect(element, target, state, body, pendingMemoPatches) {
|
|
|
2724
2728
|
emitBind(bind, target, body);
|
|
2725
2729
|
}
|
|
2726
2730
|
for (const attr of element.dynamicAttrs) {
|
|
2727
|
-
emitDynamicAttr(attr, target, body, state, pendingMemoPatches);
|
|
2731
|
+
emitDynamicAttr(attr, target, body, state, pendingMemoPatches, element.isSVG);
|
|
2728
2732
|
}
|
|
2729
2733
|
for (const spread of element.spreads) {
|
|
2730
|
-
emitSpread(spread, target, body, state, pendingMemoPatches);
|
|
2734
|
+
emitSpread(spread, target, body, state, pendingMemoPatches, element.isSVG);
|
|
2731
2735
|
}
|
|
2732
2736
|
}
|
|
2733
2737
|
function emitDynamicChildInserts(flatNodes, varMap, state, body) {
|
|
@@ -2817,7 +2821,7 @@ function emitBind(bind, target, body) {
|
|
|
2817
2821
|
if (modifiersArg) args.push(core.types.cloneNode(modifiersArg));
|
|
2818
2822
|
body.push(core.types.expressionStatement(core.types.callExpression(useImport("bindElement"), args)));
|
|
2819
2823
|
}
|
|
2820
|
-
function emitDynamicAttr(attr, target, body, state, pendingMemoPatches) {
|
|
2824
|
+
function emitDynamicAttr(attr, target, body, state, pendingMemoPatches, isSVG) {
|
|
2821
2825
|
emitPatchOrEffect(
|
|
2822
2826
|
target,
|
|
2823
2827
|
attr.name,
|
|
@@ -2825,10 +2829,11 @@ function emitDynamicAttr(attr, target, body, state, pendingMemoPatches) {
|
|
|
2825
2829
|
attr.kind,
|
|
2826
2830
|
body,
|
|
2827
2831
|
() => createEffectKey(attr.name, state.effectIndex++),
|
|
2828
|
-
pendingMemoPatches
|
|
2832
|
+
pendingMemoPatches,
|
|
2833
|
+
isSVG
|
|
2829
2834
|
);
|
|
2830
2835
|
}
|
|
2831
|
-
function emitSpread(spread, target, body, state, pendingMemoPatches) {
|
|
2836
|
+
function emitSpread(spread, target, body, state, pendingMemoPatches, isSVG) {
|
|
2832
2837
|
emitPatchOrEffect(
|
|
2833
2838
|
target,
|
|
2834
2839
|
He,
|
|
@@ -2836,19 +2841,23 @@ function emitSpread(spread, target, body, state, pendingMemoPatches) {
|
|
|
2836
2841
|
spread.kind,
|
|
2837
2842
|
body,
|
|
2838
2843
|
() => createSpreadEffectKey(state.effectIndex++),
|
|
2839
|
-
pendingMemoPatches
|
|
2844
|
+
pendingMemoPatches,
|
|
2845
|
+
isSVG
|
|
2840
2846
|
);
|
|
2841
2847
|
}
|
|
2842
|
-
function emitPatchOrEffect(target, attrName, value, kind, body, getEffectKey, pendingMemoPatches) {
|
|
2848
|
+
function emitPatchOrEffect(target, attrName, value, kind, body, getEffectKey, pendingMemoPatches, isSVG) {
|
|
2843
2849
|
if (kind === "static") {
|
|
2844
|
-
body.push(
|
|
2850
|
+
body.push(
|
|
2851
|
+
core.types.expressionStatement(createPatchCall(useImport, target, attrName, value, { isSVG }))
|
|
2852
|
+
);
|
|
2845
2853
|
return;
|
|
2846
2854
|
}
|
|
2847
2855
|
pendingMemoPatches.push({
|
|
2848
2856
|
effectKey: getEffectKey(),
|
|
2849
2857
|
target,
|
|
2850
2858
|
attrName,
|
|
2851
|
-
value
|
|
2859
|
+
value,
|
|
2860
|
+
isSVG
|
|
2852
2861
|
});
|
|
2853
2862
|
}
|
|
2854
2863
|
function emitMergedMemoEffect(patches, body) {
|
|
@@ -2870,7 +2879,8 @@ function createMemoPatchStatements(patch, memoStateId) {
|
|
|
2870
2879
|
const valueId = genUid(MEMO_NEXT_VALUE_ID);
|
|
2871
2880
|
const updateCall = createPatchCall(useImport, patch.target, patch.attrName, valueId, {
|
|
2872
2881
|
previousValue: effectState,
|
|
2873
|
-
nextValue: core.types.assignmentExpression("=", effectState, valueId)
|
|
2882
|
+
nextValue: core.types.assignmentExpression("=", effectState, valueId),
|
|
2883
|
+
isSVG: patch.isSVG
|
|
2874
2884
|
});
|
|
2875
2885
|
return [
|
|
2876
2886
|
core.types.variableDeclaration("let", [core.types.variableDeclarator(valueId, core.types.cloneNode(patch.value, true))]),
|
package/dist/index.js
CHANGED
|
@@ -1456,11 +1456,15 @@ function createPatchCall(importFn, target, attrName, value, options = {}) {
|
|
|
1456
1456
|
const { helper, name } = getPatchHelper(attrName);
|
|
1457
1457
|
const nextValue = (_a = options.nextValue) != null ? _a : value;
|
|
1458
1458
|
const isAttr = helper === "patchAttr";
|
|
1459
|
+
const emitSVGFlag = helper === "patchClass" && options.isSVG === true;
|
|
1459
1460
|
const args = isAttr ? [target, types.stringLiteral(name)] : [target];
|
|
1460
|
-
if (options.previousValue != null || options.includePreviousValuePlaceholder) {
|
|
1461
|
+
if (options.previousValue != null || options.includePreviousValuePlaceholder || emitSVGFlag) {
|
|
1461
1462
|
args.push((_b = options.previousValue) != null ? _b : types.identifier("undefined"));
|
|
1462
1463
|
}
|
|
1463
1464
|
args.push(nextValue);
|
|
1465
|
+
if (emitSVGFlag) {
|
|
1466
|
+
args.push(types.booleanLiteral(true));
|
|
1467
|
+
}
|
|
1464
1468
|
return types.callExpression(importFn(helper), args);
|
|
1465
1469
|
}
|
|
1466
1470
|
function createRefExpression(target, value) {
|
|
@@ -2722,10 +2726,10 @@ function emitElementEffect(element, target, state, body, pendingMemoPatches) {
|
|
|
2722
2726
|
emitBind(bind, target, body);
|
|
2723
2727
|
}
|
|
2724
2728
|
for (const attr of element.dynamicAttrs) {
|
|
2725
|
-
emitDynamicAttr(attr, target, body, state, pendingMemoPatches);
|
|
2729
|
+
emitDynamicAttr(attr, target, body, state, pendingMemoPatches, element.isSVG);
|
|
2726
2730
|
}
|
|
2727
2731
|
for (const spread of element.spreads) {
|
|
2728
|
-
emitSpread(spread, target, body, state, pendingMemoPatches);
|
|
2732
|
+
emitSpread(spread, target, body, state, pendingMemoPatches, element.isSVG);
|
|
2729
2733
|
}
|
|
2730
2734
|
}
|
|
2731
2735
|
function emitDynamicChildInserts(flatNodes, varMap, state, body) {
|
|
@@ -2815,7 +2819,7 @@ function emitBind(bind, target, body) {
|
|
|
2815
2819
|
if (modifiersArg) args.push(types.cloneNode(modifiersArg));
|
|
2816
2820
|
body.push(types.expressionStatement(types.callExpression(useImport("bindElement"), args)));
|
|
2817
2821
|
}
|
|
2818
|
-
function emitDynamicAttr(attr, target, body, state, pendingMemoPatches) {
|
|
2822
|
+
function emitDynamicAttr(attr, target, body, state, pendingMemoPatches, isSVG) {
|
|
2819
2823
|
emitPatchOrEffect(
|
|
2820
2824
|
target,
|
|
2821
2825
|
attr.name,
|
|
@@ -2823,10 +2827,11 @@ function emitDynamicAttr(attr, target, body, state, pendingMemoPatches) {
|
|
|
2823
2827
|
attr.kind,
|
|
2824
2828
|
body,
|
|
2825
2829
|
() => createEffectKey(attr.name, state.effectIndex++),
|
|
2826
|
-
pendingMemoPatches
|
|
2830
|
+
pendingMemoPatches,
|
|
2831
|
+
isSVG
|
|
2827
2832
|
);
|
|
2828
2833
|
}
|
|
2829
|
-
function emitSpread(spread, target, body, state, pendingMemoPatches) {
|
|
2834
|
+
function emitSpread(spread, target, body, state, pendingMemoPatches, isSVG) {
|
|
2830
2835
|
emitPatchOrEffect(
|
|
2831
2836
|
target,
|
|
2832
2837
|
He,
|
|
@@ -2834,19 +2839,23 @@ function emitSpread(spread, target, body, state, pendingMemoPatches) {
|
|
|
2834
2839
|
spread.kind,
|
|
2835
2840
|
body,
|
|
2836
2841
|
() => createSpreadEffectKey(state.effectIndex++),
|
|
2837
|
-
pendingMemoPatches
|
|
2842
|
+
pendingMemoPatches,
|
|
2843
|
+
isSVG
|
|
2838
2844
|
);
|
|
2839
2845
|
}
|
|
2840
|
-
function emitPatchOrEffect(target, attrName, value, kind, body, getEffectKey, pendingMemoPatches) {
|
|
2846
|
+
function emitPatchOrEffect(target, attrName, value, kind, body, getEffectKey, pendingMemoPatches, isSVG) {
|
|
2841
2847
|
if (kind === "static") {
|
|
2842
|
-
body.push(
|
|
2848
|
+
body.push(
|
|
2849
|
+
types.expressionStatement(createPatchCall(useImport, target, attrName, value, { isSVG }))
|
|
2850
|
+
);
|
|
2843
2851
|
return;
|
|
2844
2852
|
}
|
|
2845
2853
|
pendingMemoPatches.push({
|
|
2846
2854
|
effectKey: getEffectKey(),
|
|
2847
2855
|
target,
|
|
2848
2856
|
attrName,
|
|
2849
|
-
value
|
|
2857
|
+
value,
|
|
2858
|
+
isSVG
|
|
2850
2859
|
});
|
|
2851
2860
|
}
|
|
2852
2861
|
function emitMergedMemoEffect(patches, body) {
|
|
@@ -2868,7 +2877,8 @@ function createMemoPatchStatements(patch, memoStateId) {
|
|
|
2868
2877
|
const valueId = genUid(MEMO_NEXT_VALUE_ID);
|
|
2869
2878
|
const updateCall = createPatchCall(useImport, patch.target, patch.attrName, valueId, {
|
|
2870
2879
|
previousValue: effectState,
|
|
2871
|
-
nextValue: types.assignmentExpression("=", effectState, valueId)
|
|
2880
|
+
nextValue: types.assignmentExpression("=", effectState, valueId),
|
|
2881
|
+
isSVG: patch.isSVG
|
|
2872
2882
|
});
|
|
2873
2883
|
return [
|
|
2874
2884
|
types.variableDeclaration("let", [types.variableDeclarator(valueId, types.cloneNode(patch.value, true))]),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "babel-plugin-essor",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.18-beta.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [],
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@babel/core": "^8.0.1",
|
|
36
36
|
"@babel/generator": "^8.0.0",
|
|
37
|
-
"@estjs/shared": "0.0.
|
|
37
|
+
"@estjs/shared": "0.0.18-beta.1"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@babel/traverse": "^8.0.0",
|