-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(ssr): ensure hydrated class & style bindings are reactive
fix vuejs#7063
- Loading branch information
Showing
5 changed files
with
94 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* @flow */ | ||
|
||
import { _Set as Set, isObject } from '../util/index' | ||
import type { SimpleSet } from '../util/index' | ||
|
||
const seenObjects = new Set() | ||
|
||
/** | ||
* Recursively traverse an object to evoke all converted | ||
* getters, so that every nested property inside the object | ||
* is collected as a "deep" dependency. | ||
*/ | ||
export function traverse (val: any) { | ||
_traverse(val, seenObjects) | ||
seenObjects.clear() | ||
} | ||
|
||
function _traverse (val: any, seen: SimpleSet) { | ||
let i, keys | ||
const isA = Array.isArray(val) | ||
if ((!isA && !isObject(val)) || !Object.isExtensible(val)) { | ||
return | ||
} | ||
if (val.__ob__) { | ||
const depId = val.__ob__.dep.id | ||
if (seen.has(depId)) { | ||
return | ||
} | ||
seen.add(depId) | ||
} | ||
if (isA) { | ||
i = val.length | ||
while (i--) _traverse(val[i], seen) | ||
} else { | ||
keys = Object.keys(val) | ||
i = keys.length | ||
while (i--) _traverse(val[keys[i]], seen) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters