Skip to content

Commit

Permalink
Add support for dom events on wrapper nodes #6171
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiu committed Jan 1, 2025
1 parent 4f83a66 commit 31a7b6a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 15 deletions.
27 changes: 18 additions & 9 deletions src/manager/Component.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,15 @@ class Component extends Base {
return null
}

/**
* Returns the object associated to the key, or null if there is none.
* @param key
* @returns {Neo.component.Base|null}
*/
get(key) {
return this.wrapperNodes.get(key) || super.get(key)
}

/**
* Returns all child components which are recursively matched via their parentId
* @param {Neo.component.Base} component
Expand Down Expand Up @@ -241,14 +250,14 @@ class Component extends Base {
* @returns {Neo.component.Base|null|Neo.component.Base[]}
*
* @example
// as String: ntype[comma separated propterties]
Neo.first('toolbar button[text=Try me,icon=people]')
// as Object: Add properties. ntype is optional
Neo.first({
// as String: ntype[comma separated propterties]
Neo.first('toolbar button[text=Try me,icon=people]')
// as Object: Add properties. ntype is optional
Neo.first({
icon: 'people'
})
// as Array: An Array of Objects. No Strings allowed
Neo.first([{
// as Array: An Array of Objects. No Strings allowed
Neo.first([{
ntype: 'toolbar'
},{
ntype: 'button', text: 'Try me', icon: 'people
Expand All @@ -258,7 +267,7 @@ class Component extends Base {
* not stop after the first result.
*
* @example
Neo.first('button', false) // => [Button, Button, Button]
Neo.first('button', false) // => [Button, Button, Button]
*/
getFirst(componentDescription, returnFirstMatch = true) {
let objects = [],
Expand All @@ -279,7 +288,7 @@ class Component extends Base {

if (pairs) {
const pairsRegex = /\[(.*?)\]/,
pairsMatch = pairs.match(pairsRegex);
pairsMatch = pairs.match(pairsRegex);

if (pairsMatch) {
const pairs = pairsMatch[1].split(',');
Expand Down Expand Up @@ -345,7 +354,7 @@ class Component extends Base {
len = path?.length || 0;

for (; i < len; i++) {
if (me.has(path[i])) {
if (me.has(path[i]) || me.wrapperNodes.get(path[i])) {
componentPath.push(path[i])
}
}
Expand Down
11 changes: 5 additions & 6 deletions src/manager/DomEvent.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ class DomEvent extends Base {
opts : config,
priority : config.priority,
scope : config.scope || scope,
vnodeId : config.vnodeId || scope.id
vnodeId : config.vnodeId || scope.vdom.id
};
}

Expand Down Expand Up @@ -427,15 +427,15 @@ class DomEvent extends Base {
if (!eventConfigKeys.includes(key)) {
me.register({
bubble : domListener.bubble || value.bubble,
delegate : domListener.delegate || value.delegate || '#' + component.id,
delegate : domListener.delegate || value.delegate || '#' + component.vdom.id,
eventName : key,
id : component.id,
id : component.vdom.id, // honor wrapper nodes
opts : value,
originalConfig: domListener,
ownerId : component.id,
priority : domListener.priority || value.priority || 1,
scope : domListener.scope || component,
vnodeId : domListener.vnodeId || value.vnodeId || component.id
vnodeId : domListener.vnodeId || value.vnodeId || component.vdom.id
})
}
})
Expand Down Expand Up @@ -468,8 +468,7 @@ class DomEvent extends Base {
if (j != null) {
targetId = path[j].id
}
}
else {
} else {
let delegationArray = delegate.split(' '),
len = delegationArray.length,
hasMatch, i, item, isId;
Expand Down

0 comments on commit 31a7b6a

Please sign in to comment.