more tweaking...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2019-06-02 17:59:30 +03:00
parent 2f5144f2d8
commit 4ae0323eb2

View File

@ -2072,6 +2072,23 @@ var BaseBrowserPrototype = {
// root: <root-browser>, // root: <root-browser>,
// options: <options>, // options: <options>,
// //
//
// // These are the same as in options...
// //
// // NOTE: these will get set to the item indexes...
// from: <index> | <query>,
// to: <index> | <query>,
// // optional...
// // NOTE: in general we set these in options...
// //around: <index> | <query>,
// //count: <number>,
//
// ...
// }
//
//
// options:
// {
// // Partial render parameters... // // Partial render parameters...
// // // //
// // supported combinations: // // supported combinations:
@ -2088,12 +2105,6 @@ var BaseBrowserPrototype = {
// around: <index> | <query>, // around: <index> | <query>,
// count: <number>, // count: <number>,
// //
// ...
// }
//
//
// options:
// {
// nonFinalized: <bool>, // nonFinalized: <bool>,
// //
// // for more supported options see: .walk(..) // // for more supported options see: .walk(..)
@ -2124,16 +2135,28 @@ var BaseBrowserPrototype = {
context.options = context.options || options context.options = context.options || options
// build range bounds... // build range bounds...
// use .get(..) on full (non-partial) range...
var get_options = Object.assign(
Object.create(options),
{from: null, to: null, around: null})
// index getter...
var normIndex = function(i){ var normIndex = function(i){
return (i === undefined || typeof(i) == typeof(123)) ? return (i === undefined || typeof(i) == typeof(123)) ?
i i
: this.get(i, function(e, i){ return i }) }.bind(this) : this.get(i, function(e, i){ return i }, get_options) }.bind(this)
var from = context.from = normIndex(context.from) // NOTE: we prefer context.from / context.to as they are more
var to = context.to = normIndex(context.to) // likely to be normalized.
var around = normIndex(context.around) // as to the rest of the values of set we look first in the
var count = context.count < 0 ? // options as we'll need them only if from/to are not
// normalized...
var from = context.from = normIndex(context.from || options.from)
var to = context.to = normIndex(context.to || options.to)
var around = normIndex(options.around || context.around)
var count = options.count || context.count
// NOTE: count < 0 is the same as no count / all...
count = count < 0 ?
null null
: context.count : count
// complete to/from based on count and/or around... // complete to/from based on count and/or around...
// NOTE: we do not care about overflow here... // NOTE: we do not care about overflow here...
;(from == null && count != null) ;(from == null && count != null)