mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-28 18:00:09 +00:00
found a really odd bug, investigating...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
ad47d8036c
commit
e67f52e2d8
@ -842,6 +842,11 @@ var BaseBrowserPrototype = {
|
|||||||
// XXX which of the forms should be documented in the signature???
|
// XXX which of the forms should be documented in the signature???
|
||||||
// NOTE: it does not matter which is used as we manually
|
// NOTE: it does not matter which is used as we manually
|
||||||
// parse arguments...
|
// parse arguments...
|
||||||
|
// XXX BUG: indexes broken on reverse walking...
|
||||||
|
// to reproduce:
|
||||||
|
// dialog_1.walk2((e, i, p) => i, {reverse: false}) //-> correct numbers
|
||||||
|
// dialog_1.walk2((e, i, p) => i, {reverse: 'flat'}) //-> mess
|
||||||
|
// dialog_1.walk2((e, i, p) => i, {reverse: 'tree'}) //-> mess
|
||||||
// XXX can this be simpler???
|
// XXX can this be simpler???
|
||||||
walk2: function(func, recursion, walkable, options){
|
walk2: function(func, recursion, walkable, options){
|
||||||
var that = this
|
var that = this
|
||||||
@ -872,7 +877,7 @@ var BaseBrowserPrototype = {
|
|||||||
: null
|
: null
|
||||||
options = args.shift() || {}
|
options = args.shift() || {}
|
||||||
|
|
||||||
// recursion context...
|
// build context...
|
||||||
var context = args.shift()
|
var context = args.shift()
|
||||||
var path = context instanceof Array ?
|
var path = context instanceof Array ?
|
||||||
context
|
context
|
||||||
@ -881,7 +886,7 @@ var BaseBrowserPrototype = {
|
|||||||
{path: path}
|
{path: path}
|
||||||
: (context || {})
|
: (context || {})
|
||||||
context.root = context.root || this
|
context.root = context.root || this
|
||||||
var i = context.index = context.index || 0
|
context.index = context.index || 0
|
||||||
|
|
||||||
// options specifics...
|
// options specifics...
|
||||||
var iterateNonIterable = options.iterateAll || options.iterateNonIterable
|
var iterateNonIterable = options.iterateAll || options.iterateNonIterable
|
||||||
@ -904,6 +909,9 @@ var BaseBrowserPrototype = {
|
|||||||
|
|
||||||
return walk(
|
return walk(
|
||||||
function(state, node, next, stop){
|
function(state, node, next, stop){
|
||||||
|
// stop all instances...
|
||||||
|
//stop = context.stop = stop
|
||||||
|
|
||||||
// skip non-iterable items...
|
// skip non-iterable items...
|
||||||
if(!iterateNonIterable && node.noniterable){
|
if(!iterateNonIterable && node.noniterable){
|
||||||
return state
|
return state
|
||||||
@ -946,11 +954,12 @@ var BaseBrowserPrototype = {
|
|||||||
next('do', state, ...(reverse ? list.slice().reverse() : list))
|
next('do', state, ...(reverse ? list.slice().reverse() : list))
|
||||||
// user-defined recursion...
|
// user-defined recursion...
|
||||||
: recursion instanceof Function ?
|
: recursion instanceof Function ?
|
||||||
recursion.call(that, list, i, p, options, context, func, stop, useWalk)
|
recursion.call(that, list, context.index, p, options, context, func, useWalk)
|
||||||
// method with arg forming...
|
// method with arg forming...
|
||||||
: formArgs instanceof Function
|
: formArgs instanceof Function
|
||||||
&& list[recursion] ?
|
&& list[recursion] ?
|
||||||
list[recursion](...(formArgs(list, i, p, options, context, func, stop) || []))
|
list[recursion](
|
||||||
|
...(formArgs(list, context.index, p, options, context, func) || []))
|
||||||
: useWalk())
|
: useWalk())
|
||||||
.run(function(){
|
.run(function(){
|
||||||
// normalize...
|
// normalize...
|
||||||
@ -960,7 +969,7 @@ var BaseBrowserPrototype = {
|
|||||||
// merge recursion results into states...
|
// merge recursion results into states...
|
||||||
if(!(list === false || list instanceof Array)){
|
if(!(list === false || list instanceof Array)){
|
||||||
state.splice(state.length, 0, ...nested)
|
state.splice(state.length, 0, ...nested)
|
||||||
i += nested.length
|
context.index += nested.length
|
||||||
}
|
}
|
||||||
return nested
|
return nested
|
||||||
})
|
})
|
||||||
@ -991,7 +1000,7 @@ var BaseBrowserPrototype = {
|
|||||||
state.splice(state.length, 0,
|
state.splice(state.length, 0,
|
||||||
...[ func ?
|
...[ func ?
|
||||||
(func.call(that,
|
(func.call(that,
|
||||||
...(inline ? [null, i] : [node, i++]),
|
...(inline ? [null, context.index] : [node, context.index++]),
|
||||||
p,
|
p,
|
||||||
doNested,
|
doNested,
|
||||||
stop,
|
stop,
|
||||||
@ -1009,6 +1018,7 @@ var BaseBrowserPrototype = {
|
|||||||
function(state, mode){
|
function(state, mode){
|
||||||
// if we stopped, thread the stop up...
|
// if we stopped, thread the stop up...
|
||||||
mode == 'stopped'
|
mode == 'stopped'
|
||||||
|
&& context.root !== that
|
||||||
&& context.stop instanceof Function
|
&& context.stop instanceof Function
|
||||||
&& context.stop(state)
|
&& context.stop(state)
|
||||||
// normalize the result...
|
// normalize the result...
|
||||||
@ -1208,8 +1218,7 @@ var BaseBrowserPrototype = {
|
|||||||
args.shift()
|
args.shift()
|
||||||
: undefined
|
: undefined
|
||||||
options = args.shift() || {}
|
options = args.shift() || {}
|
||||||
|
var context = args.shift()
|
||||||
var context = args.pop()
|
|
||||||
|
|
||||||
// pattern -- normalize and pattern keywords...
|
// pattern -- normalize and pattern keywords...
|
||||||
pattern = options.ignoreKeywords ?
|
pattern = options.ignoreKeywords ?
|
||||||
@ -1262,9 +1271,7 @@ var BaseBrowserPrototype = {
|
|||||||
// index...
|
// index...
|
||||||
: typeof(pattern) == typeof(123) ?
|
: typeof(pattern) == typeof(123) ?
|
||||||
function(elem, i, path){
|
function(elem, i, path){
|
||||||
return elem
|
return i == pattern }
|
||||||
&& path.length > 0
|
|
||||||
&& i == pattern }
|
|
||||||
// object query...
|
// object query...
|
||||||
: function(elem){
|
: function(elem){
|
||||||
return Object.entries(pattern)
|
return Object.entries(pattern)
|
||||||
@ -1292,9 +1299,9 @@ var BaseBrowserPrototype = {
|
|||||||
|
|
||||||
return this.walk2(
|
return this.walk2(
|
||||||
function(elem, i, path, _, stop){
|
function(elem, i, path, _, stop){
|
||||||
console.log('---', path.join('/'))
|
console.log('--', i, path.join('/'))
|
||||||
// match...
|
// match...
|
||||||
var res = (elem
|
var res = (elem
|
||||||
&& (test === true
|
&& (test === true
|
||||||
|| test.call(this, elem, i, path))) ?
|
|| test.call(this, elem, i, path))) ?
|
||||||
[ func ?
|
[ func ?
|
||||||
@ -1304,14 +1311,13 @@ var BaseBrowserPrototype = {
|
|||||||
return ((options.firstMatch
|
return ((options.firstMatch
|
||||||
|| typeof(pattern) == typeof(123))
|
|| typeof(pattern) == typeof(123))
|
||||||
&& res.length > 0) ?
|
&& res.length > 0) ?
|
||||||
// XXX BUG: from nested browsers this does not stop
|
stop(res)
|
||||||
// the current level...
|
|
||||||
stop(res)
|
|
||||||
: res },
|
: res },
|
||||||
'search',
|
'search',
|
||||||
function(_, i, p, options, context){
|
function(_, i, p, options, context){
|
||||||
return [pattern, func, options, context] },
|
return [pattern, func, options, context] },
|
||||||
options, context)
|
options,
|
||||||
|
context)
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user