diff --git a/src/directives/public/for.js b/src/directives/public/for.js index 1294bd715..b66e41f6b 100644 --- a/src/directives/public/for.js +++ b/src/directives/public/for.js @@ -16,8 +16,7 @@ import { def, cancellable, isArray, - isPlainObject, - findVmFromFrag + isPlainObject } from '../../util/index' let uid = 0 @@ -658,4 +657,22 @@ if (process.env.NODE_ENV !== 'production') { } } +/** + * Find a vm from a fragment. + * + * @param {Fragment} frag + * @return {Vue|undefined} + */ + +function findVmFromFrag (frag) { + let node = frag.node + // handle multi-node frag + if (frag.end) { + while (!node.__vue__ && node !== frag.end && node.nextSibling) { + node = node.nextSibling + } + } + return node.__vue__ +} + export default vFor diff --git a/src/directives/public/if.js b/src/directives/public/if.js index fcf9a973e..324e548ff 100644 --- a/src/directives/public/if.js +++ b/src/directives/public/if.js @@ -5,8 +5,7 @@ import { remove, replace, createAnchor, - warn, - findVmFromFrag + warn } from '../../util/index' export default { diff --git a/src/util/dom.js b/src/util/dom.js index 38f43f72a..26382953e 100644 --- a/src/util/dom.js +++ b/src/util/dom.js @@ -449,21 +449,3 @@ export function getOuterHTML (el) { return container.innerHTML } } - -/** - * Find a vm from a fragment. - * - * @param {Fragment} frag - * @return {Vue|undefined} - */ - -export function findVmFromFrag (frag) { - let node = frag.node - // handle multi-node frag - if (frag.end) { - while (!node.__vue__ && node !== frag.end && node.nextSibling) { - node = node.nextSibling - } - } - return node.__vue__ -} diff --git a/test/unit/specs/directives/public/for/for_spec.js b/test/unit/specs/directives/public/for/for_spec.js index 877c1fa6d..379d09d20 100644 --- a/test/unit/specs/directives/public/for/for_spec.js +++ b/test/unit/specs/directives/public/for/for_spec.js @@ -1002,7 +1002,7 @@ describe('v-for', function () { expect('Frozen v-for objects cannot be automatically tracked').toHaveBeenWarned() }) - it('warn v-if and v-for mixed usage', () => { + it('warn v-if and v-for mixed usage', function () { new Vue({ el: document.createElement('div'), template: '
',