notes and tweaks...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2019-06-23 05:07:06 +03:00
parent 9c0f48ea3b
commit fb36d3660f
2 changed files with 22 additions and 10 deletions

View File

@ -222,9 +222,12 @@ requirejs([
// XXX this is not supported by .map(..)... // XXX this is not supported by .map(..)...
make.nest('$ne$sted', browser.Browser(function(make){ make.nest('$ne$sted', browser.Browser(function(make){
make('ab') make('ab')
make($('<img src="../../experiments/grayscale.jpg">')) //make('<img src="../../experiments/grayscale.jpg">',
//make($('<img src="../../experiments/grayscale.jpg">')[0]) //make($('<img src="../../experiments/grayscale.jpg">')[0],
//make('<img src="../../experiments/grayscale.jpg">') make($('<img src="../../experiments/grayscale.jpg">'),
{
alt: 'image item example'
})
})), })),
]) ])
make('in between two $subtrees...') make('in between two $subtrees...')

View File

@ -3760,9 +3760,19 @@ var BrowserPrototype = {
item.disabled item.disabled
|| elem.setAttribute('tabindex', '0') || elem.setAttribute('tabindex', '0')
Object.entries(item.attrs || {}) Object.entries(item.attrs || {})
// shorthand attrs...
.concat([
'alt'
].map(function(key){
return [key, item[key]] }))
.forEach(function([key, value]){ .forEach(function([key, value]){
elem.setAttribute(key, value) }) value !== undefined
elem.setAttribute('value', text) && elem.setAttribute(key, value) })
elem.setAttribute('value',
// XXX should text handling be done here only or globally above???
typeof(text) == typeof('str') ?
text
: item.alt || item.id)
// values... // values...
text != null text != null
@ -3823,7 +3833,7 @@ var BrowserPrototype = {
// buttons... // buttons...
var button_keys = {} var button_keys = {}
// XXX migrate the default buttons functionality and button inheritance... // XXX migrate button inheritance...
var buttons = (item.buttons || options.itemButtons || []) var buttons = (item.buttons || options.itemButtons || [])
// resolve buttons from library... // resolve buttons from library...
.map(function(button){ .map(function(button){
@ -3837,7 +3847,6 @@ var BrowserPrototype = {
.reverse() .reverse()
var stopPropagation = function(evt){ evt.stopPropagation() } var stopPropagation = function(evt){ evt.stopPropagation() }
buttons buttons
// XXX use keyword to inherit buttons...
.forEach(function([html, handler, ...rest]){ .forEach(function([html, handler, ...rest]){
var force = (rest[0] === true var force = (rest[0] === true
|| rest[0] === false || rest[0] === false
@ -3846,7 +3855,7 @@ var BrowserPrototype = {
: undefined : undefined
var metadata = rest.shift() || {} var metadata = rest.shift() || {}
// resolve metadata... // metadata...
var cls = metadata.cls || [] var cls = metadata.cls || []
cls = cls instanceof Function ? cls = cls instanceof Function ?
cls.call(that, item) cls.call(that, item)
@ -3869,7 +3878,7 @@ var BrowserPrototype = {
setDOMValue(button, setDOMValue(button,
resolveValue(html, Items.buttons, {item})) resolveValue(html, Items.buttons, {item}))
// active button... // non-disabled button...
if(force instanceof Function ? if(force instanceof Function ?
force.call(that, item) force.call(that, item)
: (force || !item.disabled) ){ : (force || !item.disabled) ){
@ -3914,7 +3923,7 @@ var BrowserPrototype = {
that[a.action](...a.arguments) } that[a.action](...a.arguments) }
// handle clicks and keyboard... // handle clicks and keyboard...
button.addEventListener('click', func) button.addEventListener('click', func.bind(that))
// NOTE: we only trigger buttons on Enter and do // NOTE: we only trigger buttons on Enter and do
// not care about other keys... // not care about other keys...
button.addEventListener('keydown', button.addEventListener('keydown',