Skip to content

Commit d9c3fd5

Browse files
dxvladislavvolkovdxvladislavvolkovdxvladislavvolkovdxvladislavvolkovteabagp
authored
Process a bail container of nested components (T1097275) (#628)
* Fix template rendering with router-view inside * Fix security alerts * Fix conditional render for config components * Fix v-model with argument after bc * Use sync template for dxForm * Process a bail container of nested components Co-authored-by: dxvladislavvolkov <[email protected]> Co-authored-by: dxvladislavvolkov <[email protected]> Co-authored-by: dxvladislavvolkov <[email protected]> Co-authored-by: teabagp <[email protected]>
1 parent 04a5686 commit d9c3fd5

File tree

2 files changed

+29
-4
lines changed

2 files changed

+29
-4
lines changed

packages/devextreme-vue/src/core/__tests__/component.test.ts

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1+
import { PatchFlags } from "@vue/shared";
12
import { mount } from "@vue/test-utils";
23
import * as events from "devextreme/events";
3-
import { App, defineComponent, nextTick } from "vue";
4+
import { App, createVNode, defineComponent, h, nextTick, renderSlot } from "vue";
45
import { createRouter, createWebHistory } from "vue-router";
56

7+
import { pullConfigComponents } from "../children-processing";
68
import { IWidgetComponent } from "../component";
79
import globalConfig from "../config";
10+
import Configuration from "../configuration";
811
import { IConfigurable, IConfigurationComponent } from "../configuration-component";
912
import { IExtension } from "../extension-component";
1013
import { createComponent, createConfigurationComponent, createExtensionComponent } from "../index";
@@ -1815,3 +1818,25 @@ describe("disposing", () => {
18151818
expect(component.unmount.bind(component)).not.toThrow();
18161819
});
18171820
});
1821+
1822+
describe("children processing", () => {
1823+
it("should process children if they are wrapped to a bail container", () => {
1824+
const Nested = buildTestConfigCtor();
1825+
const config = new Configuration(
1826+
() => undefined,
1827+
null,
1828+
{}
1829+
);
1830+
(Nested as any as IConfigurationComponent).$_optionName = "nestedOption";
1831+
const nestedVNode = createVNode(Nested);
1832+
const vnode = renderSlot(
1833+
{ default: () => [nestedVNode] },
1834+
"default",
1835+
undefined,
1836+
() => [(h("comment"))]
1837+
);
1838+
expect(vnode.patchFlag).toBe(PatchFlags.BAIL);
1839+
pullConfigComponents([vnode], [], config);
1840+
expect(nestedVNode).toHaveProperty("$_config");
1841+
});
1842+
});

packages/devextreme-vue/src/core/children-processing.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ export function isFragment(node: any): boolean {
1414
const patchFlag = node.patchFlag;
1515
return patchFlag === PatchFlags.KEYED_FRAGMENT
1616
|| patchFlag === PatchFlags.UNKEYED_FRAGMENT
17-
|| patchFlag === PatchFlags.STABLE_FRAGMENT;
17+
|| patchFlag === PatchFlags.STABLE_FRAGMENT
18+
|| patchFlag === PatchFlags.BAIL;
1819
}
1920

20-
function pullConfigComponents(children: VNode[], nodes: VNode[], ownerConfig: Configuration): void {
21-
21+
export function pullConfigComponents(children: VNode[], nodes: VNode[], ownerConfig: Configuration): void {
2222
children.forEach((node) => {
2323
if (isFragment(node) && Array.isArray(node.children)) {
2424
pullConfigComponents(node.children as any as VNode[], nodes, ownerConfig);

0 commit comments

Comments
 (0)