10000 fix: clone modal context.config and globalProperties to not mutate ro… · smather/nativescript-vue@bb5a629 · GitHub
[go: up one dir, main page]

Skip to content

Commit bb5a629

Browse files
committed
fix: clone modal context.config and globalProperties to not mutate root context
1 parent f2045ab commit bb5a629

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/plugins/modals.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,17 @@ export async function $showModal<T = any, P = any>(
130130
view.nativeView?.closeModal(...args);
131131
};
132132

133-
view.context.config.globalProperties.$closeModal = closeModal;
134-
view.context.config.globalProperties.$modal = { close: closeModal };
133+
// clone the config and globalProperties to avoid mutating the root app's config/globalProperties
134+
const context = view.context;
135+
context.config = Object.assign({}, context.config);
136+
context.config.globalProperties = Object.assign(
137+
{},
138+
context.config.globalProperties,
139+
{
140+
$closeModal: closeModal,
141+
$modal: { close: closeModal },
142+
},
143+
);
135144

136145
view.mount(root);
137146
openModal();

0 commit comments

Comments
 (0)
0