cleanup...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2026-06-28 16:04:45 +03:00
parent 8b5f156816
commit 3829ce9764
2 changed files with 7 additions and 101 deletions

View File

@ -1287,9 +1287,10 @@ module.parser = {
// are contained in, this will not lead to recursion. // are contained in, this will not lead to recursion.
// //
// XXX do we actually need <content/>?? // XXX do we actually need <content/>??
// <slot slot> // <slot slot>
// <slot slot.content/> // <slot slot.content/>
// </slot> // </slot>
// nesting slots basically does the same thing...
// XXX do we show a slot with unfilled content??? // XXX do we show a slot with unfilled content???
// ...what's the point in having <content>, can't is just // ...what's the point in having <content>, can't is just
// be replaced by a slot? // be replaced by a slot?
@ -1321,43 +1322,6 @@ module.parser = {
: name in slots) : name in slots)
// set slot value... // set slot value...
/* XXX CONTENT...
var stack = []
slots[name]
&& stack.push(slots[name])
delete slots[name]
text = text ?
parser.expand(this, text ?? [], state)
: text
if(body && text){
stack.push(body)
var slot = text
} else {
var slot = body ?? text }
var original = slot
slots[name]
&& stack.unshift(slot)
slot = slots[name] ??= slot
// handle <content/>...
for(prev of stack.reverse()){
// get the first <content/>
// NOTE: this is a flat search because we can't
// have indirect nesting (see: .group(..))
for(var i in prev){
if(typeof(prev[i]) != 'string'
&& prev[i].name == 'content'){
break }
i = null }
i != null
&& (prev[i].value = [...slot])
&& slot.splice(0, slot.length,
...prev
// remove nested slot handlers...
// XXX do we need this???
.filter(function(e){
return typeof(e) != 'function'
|| e.slot != name }) ) }
/*/
text = text ? text = text ?
parser.expand(this, text ?? [], state) parser.expand(this, text ?? [], state)
: text : text
@ -1365,18 +1329,15 @@ module.parser = {
var slot = text var slot = text
} else { } else {
var slot = body ?? text } var slot = body ?? text }
var original = slot
slots[name] = slot slots[name] = slot
//*/
return hidden ? return hidden ?
'' ''
: Object.assign( : Object.assign(
function(st){ function(st){
return ((st ?? state).slots ?? {})[name] return ((st ?? state).slots ?? {})[name]
?? original }, ?? slot },
{slot: name}) }) }), {slot: name}) }) }),
// XXX CONTENT...
//'content': ['slot'],
// //

View File

@ -54,25 +54,6 @@ test.Setups({
...ins.map(function(e){ ...ins.map(function(e){
return e + '<slot slot>third</slot>' }), return e + '<slot slot>third</slot>' }),
'third' ] }, 'third' ] },
/* XXX CONTENT...
slot_content_empty: function(assert){
return [
'@slot(slot body="[[ <content/> ]]")',
'<slot slot>[[ <content/> ]]</slot>',
'[[ ]]' ] },
slot_content_default: function(assert){
return [
'@slot(slot default body="[[ <content/> ]]")',
'<slot slot default>[[ <content/> ]]</slot>',
'[[ default ]]' ] },
slot_content_fill: function(assert){
var ins = this.slot_content_default(assert)
var expect = ins.pop()
return [
...ins.map(function(i){
return i +'@slot(slot value)' }),
expect.replace('default', 'value') ] },
//*/
// XXX these are an alternative to <content/>... // XXX these are an alternative to <content/>...
slot_nested: function(assert){ slot_nested: function(assert){
@ -84,43 +65,7 @@ test.Setups({
'<slot slot>[[ <slot slot.content/> ]]</slot>@slot(slot value)', '<slot slot>[[ <slot slot.content/> ]]</slot>@slot(slot value)',
'value' ] }, 'value' ] },
/* XXX CONTENT... /* XXX SHOWN_HIDDEN
// XXX the question with the next tow is:
// should body override or nest?
// ...both are logical but in either case the result should be
// consistent.
//
// XXX should the new body/content override or expand the original???
slot_content_content: function(assert){
var ins = this.slot_content_default(assert)
var expect = ins.pop()
return [
...ins.map(function(i){
return i +'@slot(slot body="(( @content() ))")' }),
// XXX should this override the default above???
//expect.replace('default', '(( default ))') ] },
expect.replace('default', '(( ))') ] },
slot_content_content_content: function(assert){
var ins = this.slot_content_content(assert)
var expect = ins.pop()
return [
...ins.map(function(i){
return i +'@slot(slot body="<< @content() >>")' }),
// XXX should this override the default above???
//expect.replace('default', '(( default ))') ] },
expect.replace('(( ))', '(( << >> ))') ] },
// XXX if we are expanding (see above) why are we overriding here???
slot_content_content_fill: function(assert){
var ins = this.slot_content_content(assert)
var expect = ins.pop()
return [
...ins.map(function(i){
return i +'@slot(slot value)' }),
expect.replace('(( ))', '(( value ))') ] },
//expect.replace('(( ))', 'value') ] },
//
// XXX these need to be revised... // XXX these need to be revised...
// ...do we actually need hidden/shown??? // ...do we actually need hidden/shown???
// //