Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[js] correct foreach to for each. #3243

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions runtime/frameworks/legacy/vm/compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ import {
* build()
* compile(template, parentNode)
* if (type is content) create contentNode
* else if (dirs have v-for) foreach -> create context
* else if (dirs have v-for) for each -> create context
* -> compile(templateWithoutFor, parentNode): diff(list) onchange
* else if (dirs have v-if) assert
* -> compile(templateWithoutIf, parentNode): toggle(shown) onchange
Expand All @@ -60,11 +60,11 @@ import {
* else if (type is custom)
* addChildVm(vm, parentVm)
* build(externalDirs)
* foreach childNodes -> compile(childNode, template)
* for each childNodes -> compile(childNode, template)
* else if (type is native)
* set(dirs): update(id/attr/style/class) onchange
* append(template, parentNode)
* foreach childNodes -> compile(childNode, template)
* for each childNodes -> compile(childNode, template)
*/
export function build (vm) {
const opt = vm._options || {}
Expand Down Expand Up @@ -497,7 +497,7 @@ function bindRepeat (vm, target, fragBlock, info) {
trackMap[key] = item
})

// 2. remove unused element foreach old item
// 2. remove unused element for each old item
const reusedList = []
oldData.forEach((item, index) => {
const key = trackBy ? item[trackBy] : (oldStyle ? item[keyName] : index)
Expand All @@ -514,7 +514,7 @@ function bindRepeat (vm, target, fragBlock, info) {
}
})

// 3. create new element foreach new item
// 3. create new element for each new item
children.length = 0
vms.length = 0
fragBlock.data = data.slice()
Expand Down