experimenting with different approches to render...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2019-08-30 18:32:23 +03:00
parent 031c179e4d
commit d74482e037

View File

@ -3657,7 +3657,10 @@ var BaseBrowserPrototype = {
options = context.options = context.options options = context.options = context.options
|| Object.assign( || Object.assign(
Object.create(this.options || {}), Object.create(this.options || {}),
{ iterateNonIterable: true }, {
iterateNonIterable: true,
includeInlinedBlocks: true,
},
options || {}) options || {})
var section = options.section || '*' var section = options.section || '*'
@ -3780,24 +3783,25 @@ var BaseBrowserPrototype = {
: (filter && !filter.call(this, elem, i, path, section)) ? : (filter && !filter.call(this, elem, i, path, section)) ?
[] []
// out of range -> skip... // out of range -> skip...
// XXX should we stop() here???
: ((from != null && i < from) : ((from != null && i < from)
|| (to != null && i >= to)) ? || (to != null && i >= to)) ?
[] []
// inline... // inline (list)...
: elem == null ? : elem instanceof Array ?
// NOTE: here we are forcing rendering of the
// inline browser/list, i.e. ignoring
// options.skipNested for inline stuff...
[ renderer.renderGroup(nested(true), context) ] [ renderer.renderGroup(nested(true), context) ]
// inline (browser)...
: elem instanceof BaseBrowser ?
(nested(false),
[ renderer.renderGroup(elem.render(options, renderer, context), context) ])
// nested... // nested...
: elem.children ? : elem.children ?
[ renderer.renderNested( [ renderer.renderNested(
renderer.renderNestedHeader(elem, i, context), renderer.renderNestedHeader(elem, i, context),
// XXX this renders the elements seporately elem.children instanceof BaseBrowser ?
// in one flat list, need to stop auto-recursion (nested(false),
// down and call .render(..) elem.children.render(options, renderer, context))
// XXX : nested(true),
nested(true),
elem, elem,
context) ] context) ]
// normal elem... // normal elem...
@ -3973,6 +3977,50 @@ var BaseBrowserPrototype = {
: items } }, : items } },
//*/ //*/
render2: function(options, renderer, context){
// XXX args...
// XXX rendering...
var inline = function(lst){
return lst }
var nest = function(header, lst){
return [
header,
...lst.map(function(e){
return header +'/'+ e })]}
var elem = function(e){
return e.id || e }
return this.walk2(function(e, i, p, children){
// do not go down child browsers -- use their mechanics for rendering...
;(e instanceof BaseBrowser || e.children instanceof BaseBrowser)
&& children(false)
return (
// inlined...
e instanceof BaseBrowser ?
inline(e.render2(options, renderer, context))
: e instanceof Array ?
inline(children(true))
// nested...
: e.children instanceof BaseBrowser ?
nest(elem(e), e.children.render2(options, renderer, context))
: e.children instanceof Array ?
nest(elem(e), children(true))
// normal item...
: elem(e) )
}, {
includeInlinedBlocks: true,
iterateNonIterable: true,
})
},
// Events... // Events...
// //