'outer' 在此 prosemirror 代码中是什么意思?
What does 'outer' mean in this prosemirror code?
这里https://github.com/ProseMirror/prosemirror-state/blob/master/src/state.js#L122是prosemirror js代码行:
applyTransaction(rootTr) {
//...
outer: for (;;) {
在此 javascript 代码中无限循环之前的 'outer' 是什么意思?
更新
函数的完整代码:
applyTransaction(rootTr) {
if (!this.filterTransaction(rootTr)) return {state: this, transactions: []}
let trs = [rootTr], newState = this.applyInner(rootTr), seen = null
// This loop repeatedly gives plugins a chance to respond to
// transactions as new transactions are added, making sure to only
// pass the transactions the plugin did not see before.
outer: for (;;) { // <--- this line !!!
let haveNew = false
for (let i = 0; i < this.config.plugins.length; i++) {
let plugin = this.config.plugins[i]
if (plugin.spec.appendTransaction) {
let n = seen ? seen[i].n : 0, oldState = seen ? seen[i].state : this
let tr = n < trs.length &&
plugin.spec.appendTransaction.call(plugin, n ? trs.slice(n) : trs, oldState, newState)
if (tr && newState.filterTransaction(tr, i)) {
tr.setMeta("appendedTransaction", rootTr)
if (!seen) {
seen = []
for (let j = 0; j < this.config.plugins.length; j++)
seen.push(j < i ? {state: newState, n: trs.length} : {state: this, n: 0})
}
trs.push(tr)
newState = newState.applyInner(tr)
haveNew = true
}
if (seen) seen[i] = {state: newState, n: trs.length}
}
}
if (!haveNew) return {state: newState, transactions: trs}
}
}
这是一个label。
The labeled statement can be used with break or continue statements. It is prefixing a statement with an identifier which you can refer to.
看了一眼链接的源代码,我的第一个猜测是它在那里,所以插件可以引用它。
这里https://github.com/ProseMirror/prosemirror-state/blob/master/src/state.js#L122是prosemirror js代码行:
applyTransaction(rootTr) {
//...
outer: for (;;) {
在此 javascript 代码中无限循环之前的 'outer' 是什么意思?
更新
函数的完整代码:
applyTransaction(rootTr) {
if (!this.filterTransaction(rootTr)) return {state: this, transactions: []}
let trs = [rootTr], newState = this.applyInner(rootTr), seen = null
// This loop repeatedly gives plugins a chance to respond to
// transactions as new transactions are added, making sure to only
// pass the transactions the plugin did not see before.
outer: for (;;) { // <--- this line !!!
let haveNew = false
for (let i = 0; i < this.config.plugins.length; i++) {
let plugin = this.config.plugins[i]
if (plugin.spec.appendTransaction) {
let n = seen ? seen[i].n : 0, oldState = seen ? seen[i].state : this
let tr = n < trs.length &&
plugin.spec.appendTransaction.call(plugin, n ? trs.slice(n) : trs, oldState, newState)
if (tr && newState.filterTransaction(tr, i)) {
tr.setMeta("appendedTransaction", rootTr)
if (!seen) {
seen = []
for (let j = 0; j < this.config.plugins.length; j++)
seen.push(j < i ? {state: newState, n: trs.length} : {state: this, n: 0})
}
trs.push(tr)
newState = newState.applyInner(tr)
haveNew = true
}
if (seen) seen[i] = {state: newState, n: trs.length}
}
}
if (!haveNew) return {state: newState, transactions: trs}
}
}
这是一个label。
The labeled statement can be used with break or continue statements. It is prefixing a statement with an identifier which you can refer to.
看了一眼链接的源代码,我的第一个猜测是它在那里,所以插件可以引用它。