|
@@ -2,7 +2,7 @@ import { directive, prefix } from '../directives'
|
|
|
import { initInterceptors } from '../interceptor'
|
|
|
import { injectDataProviders } from '../datas'
|
|
|
import { addRootSelector } from '../lifecycle'
|
|
|
-import { skipDuringClone } from '../clone'
|
|
|
+import { isCloning } from '../clone'
|
|
|
import { addScopeToNode } from '../scope'
|
|
|
import { injectMagics, magic } from '../magics'
|
|
|
import { reactive } from '../reactivity'
|
|
@@ -10,7 +10,13 @@ import { evaluate } from '../evaluator'
|
|
|
|
|
|
addRootSelector(() => `[${prefix('data')}]`)
|
|
|
|
|
|
-directive('data', skipDuringClone((el, { expression }, { cleanup }) => {
|
|
|
+directive('data', ((el, { expression }, { cleanup }) => {
|
|
|
+ // If we are cloning a tree, we only want to evaluate x-data if another
|
|
|
+ // x-data context DOESN'T exist on the component.
|
|
|
+ // The reason a data context WOULD exist is that we graft root x-data state over
|
|
|
+ // from the live tree before hydrating the clone tree.
|
|
|
+ if (isCloning && el._x_dataStack) return;
|
|
|
+
|
|
|
expression = expression === '' ? '{}' : expression
|
|
|
|
|
|
let magicContext = {}
|