@dooboostore/simple-web-component 1.0.35 → 1.0.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -21
- package/dist/cjs/decorators/addEventListener.js +12 -4
- package/dist/cjs/decorators/addEventListener.js.map +2 -2
- package/dist/cjs/decorators/applyAttribute.js +19 -18
- package/dist/cjs/decorators/applyAttribute.js.map +2 -2
- package/dist/cjs/decorators/applyClass.js +23 -22
- package/dist/cjs/decorators/applyClass.js.map +2 -2
- package/dist/cjs/decorators/applyNode.js +18 -17
- package/dist/cjs/decorators/applyNode.js.map +2 -2
- package/dist/cjs/decorators/applyStyle.js +20 -19
- package/dist/cjs/decorators/applyStyle.js.map +2 -2
- package/dist/cjs/decorators/attribute.js +16 -15
- package/dist/cjs/decorators/attribute.js.map +2 -2
- package/dist/cjs/decorators/{changedAttributeHost.js → changedAttributeThis.js} +6 -6
- package/dist/cjs/decorators/changedAttributeThis.js.map +7 -0
- package/dist/cjs/decorators/elementDefine.js +21 -20
- package/dist/cjs/decorators/elementDefine.js.map +2 -2
- package/dist/cjs/decorators/emitCustomEvent.js +18 -16
- package/dist/cjs/decorators/emitCustomEvent.js.map +2 -2
- package/dist/cjs/decorators/index.js +1 -1
- package/dist/cjs/decorators/index.js.map +1 -1
- package/dist/cjs/decorators/query.js +38 -60
- package/dist/cjs/decorators/query.js.map +2 -2
- package/dist/cjs/decorators/queryAll.js +31 -63
- package/dist/cjs/decorators/queryAll.js.map +2 -2
- package/dist/cjs/decorators/setProperty.js +13 -12
- package/dist/cjs/decorators/setProperty.js.map +2 -2
- package/dist/cjs/elements/SwcAsync.js +6 -6
- package/dist/cjs/elements/SwcAsync.js.map +1 -1
- package/dist/cjs/elements/SwcChoose.js +5 -5
- package/dist/cjs/elements/SwcChoose.js.map +1 -1
- package/dist/cjs/elements/SwcIf.js +6 -6
- package/dist/cjs/elements/SwcIf.js.map +1 -1
- package/dist/cjs/elements/SwcLoop.js +5 -5
- package/dist/cjs/elements/SwcLoop.js.map +1 -1
- package/dist/cjs/elements/register.js +18 -18
- package/dist/cjs/elements/register.js.map +1 -1
- package/dist/cjs/types.js.map +1 -1
- package/dist/cjs/utils/Utils.js +13 -13
- package/dist/cjs/utils/Utils.js.map +2 -2
- package/dist/esm/decorators/addEventListener.js +12 -4
- package/dist/esm/decorators/addEventListener.js.map +2 -2
- package/dist/esm/decorators/applyAttribute.js +19 -18
- package/dist/esm/decorators/applyAttribute.js.map +2 -2
- package/dist/esm/decorators/applyClass.js +23 -22
- package/dist/esm/decorators/applyClass.js.map +2 -2
- package/dist/esm/decorators/applyNode.js +18 -17
- package/dist/esm/decorators/applyNode.js.map +2 -2
- package/dist/esm/decorators/applyStyle.js +20 -19
- package/dist/esm/decorators/applyStyle.js.map +2 -2
- package/dist/esm/decorators/attribute.js +16 -15
- package/dist/esm/decorators/attribute.js.map +2 -2
- package/dist/esm/decorators/{changedAttributeHost.js → changedAttributeThis.js} +3 -3
- package/dist/esm/decorators/changedAttributeThis.js.map +7 -0
- package/dist/esm/decorators/elementDefine.js +19 -18
- package/dist/esm/decorators/elementDefine.js.map +2 -2
- package/dist/esm/decorators/emitCustomEvent.js +18 -16
- package/dist/esm/decorators/emitCustomEvent.js.map +2 -2
- package/dist/esm/decorators/index.js +1 -1
- package/dist/esm/decorators/index.js.map +1 -1
- package/dist/esm/decorators/query.js +38 -60
- package/dist/esm/decorators/query.js.map +2 -2
- package/dist/esm/decorators/queryAll.js +31 -63
- package/dist/esm/decorators/queryAll.js.map +2 -2
- package/dist/esm/decorators/setProperty.js +13 -12
- package/dist/esm/decorators/setProperty.js.map +2 -2
- package/dist/esm/elements/SwcAsync.js +7 -7
- package/dist/esm/elements/SwcAsync.js.map +1 -1
- package/dist/esm/elements/SwcChoose.js +6 -6
- package/dist/esm/elements/SwcChoose.js.map +1 -1
- package/dist/esm/elements/SwcIf.js +7 -7
- package/dist/esm/elements/SwcIf.js.map +1 -1
- package/dist/esm/elements/SwcLoop.js +6 -6
- package/dist/esm/elements/SwcLoop.js.map +1 -1
- package/dist/esm/elements/register.js +19 -19
- package/dist/esm/elements/register.js.map +1 -1
- package/dist/esm/types.js.map +1 -1
- package/dist/esm/utils/Utils.js +13 -13
- package/dist/esm/utils/Utils.js.map +2 -2
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js +271 -308
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js.map +4 -4
- package/dist/types/decorators/addEventListener.d.ts +5 -7
- package/dist/types/decorators/addEventListener.d.ts.map +1 -1
- package/dist/types/decorators/applyAttribute.d.ts +4 -4
- package/dist/types/decorators/applyAttribute.d.ts.map +1 -1
- package/dist/types/decorators/applyClass.d.ts +6 -6
- package/dist/types/decorators/applyClass.d.ts.map +1 -1
- package/dist/types/decorators/applyNode.d.ts +6 -6
- package/dist/types/decorators/applyNode.d.ts.map +1 -1
- package/dist/types/decorators/applyStyle.d.ts +4 -4
- package/dist/types/decorators/applyStyle.d.ts.map +1 -1
- package/dist/types/decorators/attribute.d.ts +5 -5
- package/dist/types/decorators/attribute.d.ts.map +1 -1
- package/dist/types/decorators/changedAttributeThis.d.ts +18 -0
- package/dist/types/decorators/changedAttributeThis.d.ts.map +1 -0
- package/dist/types/decorators/elementDefine.d.ts.map +1 -1
- package/dist/types/decorators/emitCustomEvent.d.ts +4 -9
- package/dist/types/decorators/emitCustomEvent.d.ts.map +1 -1
- package/dist/types/decorators/index.d.ts +1 -1
- package/dist/types/decorators/query.d.ts +17 -63
- package/dist/types/decorators/query.d.ts.map +1 -1
- package/dist/types/decorators/queryAll.d.ts +6 -63
- package/dist/types/decorators/queryAll.d.ts.map +1 -1
- package/dist/types/decorators/setProperty.d.ts +1 -1
- package/dist/types/decorators/setProperty.d.ts.map +1 -1
- package/dist/types/types.d.ts +2 -2
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/utils/Utils.d.ts +7 -7
- package/dist/types/utils/Utils.d.ts.map +1 -1
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js +271 -308
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +4 -4
- package/package.json +4 -4
- package/src/decorators/addEventListener.ts +11 -9
- package/src/decorators/applyAttribute.ts +16 -15
- package/src/decorators/applyClass.ts +18 -17
- package/src/decorators/applyNode.ts +21 -20
- package/src/decorators/applyStyle.ts +17 -16
- package/src/decorators/attribute.ts +20 -19
- package/src/decorators/{changedAttributeHost.ts → changedAttributeThis.ts} +10 -12
- package/src/decorators/elementDefine.ts +21 -20
- package/src/decorators/emitCustomEvent.ts +21 -26
- package/src/decorators/index.ts +1 -1
- package/src/decorators/query.ts +51 -124
- package/src/decorators/queryAll.ts +30 -127
- package/src/decorators/setProperty.ts +12 -11
- package/src/elements/SwcAsync.ts +7 -7
- package/src/elements/SwcChoose.ts +6 -6
- package/src/elements/SwcIf.ts +8 -8
- package/src/elements/SwcLoop.ts +6 -6
- package/src/elements/register.ts +20 -20
- package/src/types.ts +5 -5
- package/src/utils/Utils.ts +17 -18
- package/dist/cjs/decorators/changedAttributeHost.js.map +0 -7
- package/dist/esm/decorators/changedAttributeHost.js.map +0 -7
- package/dist/types/decorators/changedAttributeHost.d.ts +0 -20
- package/dist/types/decorators/changedAttributeHost.d.ts.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dooboostore/simple-web-component",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.36",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/cjs/index.js",
|
|
@@ -92,10 +92,10 @@
|
|
|
92
92
|
"webpack": "^5.93.0",
|
|
93
93
|
"webpack-cli": "^5.1.4",
|
|
94
94
|
"webpack-dev-server": "^5.2.0",
|
|
95
|
-
"@dooboostore/simple-boot": "1.0.55",
|
|
96
|
-
"@dooboostore/core-node": "1.0.12",
|
|
97
95
|
"@dooboostore/core": "1.0.31",
|
|
98
|
-
"@dooboostore/core-
|
|
96
|
+
"@dooboostore/core-node": "1.0.12",
|
|
97
|
+
"@dooboostore/core-web": "1.0.10",
|
|
98
|
+
"@dooboostore/simple-boot": "1.0.55"
|
|
99
99
|
},
|
|
100
100
|
"scripts": {
|
|
101
101
|
"clean": "rm -rf dist",
|
|
@@ -47,19 +47,21 @@ export const getAddEventListenerMetadata = (target: any): AddEventListenerMetada
|
|
|
47
47
|
};
|
|
48
48
|
|
|
49
49
|
/**
|
|
50
|
-
* @
|
|
51
|
-
* Usage: @addEventListenerHost('click')
|
|
52
|
-
* Usage: @addEventListenerHost('click', { stopPropagation: true })
|
|
50
|
+
* @addEventListenerThis decorator - simplified version of @addEventListener for $this selector
|
|
53
51
|
*/
|
|
54
|
-
export function
|
|
55
|
-
return addEventListener('
|
|
52
|
+
export function addEventListenerThis(type: string, options?: AddEventListenerBaseOptions & SwcQueryOptions): MethodDecorator {
|
|
53
|
+
return addEventListener('$this', type, options);
|
|
56
54
|
}
|
|
57
55
|
|
|
58
56
|
/**
|
|
59
|
-
* @addEventListenerAppHost decorator - simplified version of @addEventListener for
|
|
60
|
-
* Usage: @addEventListenerAppHost('click')
|
|
61
|
-
* Usage: @addEventListenerAppHost('click', { stopPropagation: true })
|
|
57
|
+
* @addEventListenerAppHost decorator - simplified version of @addEventListener for $appHost selector
|
|
62
58
|
*/
|
|
63
59
|
export function addEventListenerAppHost(type: string, options?: AddEventListenerBaseOptions & SwcQueryOptions): MethodDecorator {
|
|
64
|
-
return addEventListener('
|
|
60
|
+
return addEventListener('$appHost', type, options);
|
|
61
|
+
}
|
|
62
|
+
export function addEventListenerWindow(type: string, options?: AddEventListenerBaseOptions & SwcQueryOptions): MethodDecorator {
|
|
63
|
+
return addEventListener('$window', type, options);
|
|
64
|
+
}
|
|
65
|
+
export function addEventListenerDocument(type: string, options?: AddEventListenerBaseOptions & SwcQueryOptions): MethodDecorator {
|
|
66
|
+
return addEventListener('$document', type, options);
|
|
65
67
|
}
|
|
@@ -61,15 +61,16 @@ function createAttributeDecorator(action: AttributeAction) {
|
|
|
61
61
|
targetEls.push(t);
|
|
62
62
|
};
|
|
63
63
|
|
|
64
|
-
if (selector === '
|
|
65
|
-
else if (selector === '
|
|
66
|
-
else if (selector === '
|
|
67
|
-
else if (selector === '
|
|
68
|
-
else if (selector === '
|
|
69
|
-
else if (selector === '
|
|
70
|
-
else if (selector === '
|
|
71
|
-
else if (selector === '
|
|
72
|
-
else if (selector === '
|
|
64
|
+
if (selector === '$this' || !selector) applyRoot(host);
|
|
65
|
+
else if (selector === '$host') applyRoot(hostSet.$host);
|
|
66
|
+
else if (selector === '$parentHost') applyRoot(hostSet.$parentHost);
|
|
67
|
+
else if (selector === '$appHost') applyRoot(hostSet.$appHost);
|
|
68
|
+
else if (selector === '$firstHost') applyRoot(hostSet.$firstHost);
|
|
69
|
+
else if (selector === '$lastHost') applyRoot(hostSet.$lastHost);
|
|
70
|
+
else if (selector === '$firstAppHost') applyRoot(hostSet.$firstAppHost);
|
|
71
|
+
else if (selector === '$lastAppHost') applyRoot(hostSet.$lastAppHost);
|
|
72
|
+
else if (selector === '$hosts') hostSet.$hosts.forEach(applyRoot);
|
|
73
|
+
else if (selector === '$appHosts') hostSet.$appHosts.forEach(applyRoot);
|
|
73
74
|
else {
|
|
74
75
|
const targetRoot = r === 'auto' ? (host.shadowRoot || host) : (r === 'shadow' ? host.shadowRoot : host);
|
|
75
76
|
if (targetRoot) {
|
|
@@ -140,13 +141,13 @@ export const setAttribute = (selector: string, nameOrOptions?: string | Attribut
|
|
|
140
141
|
export const updateAttribute = (selector: string, nameOrOptions?: string | AttributeApplyOptions, options: AttributeApplyOptions = {}) => createAttributeDecorator('update')(selector, nameOrOptions, options);
|
|
141
142
|
export const removeAttribute = (selector: string, nameOrOptions?: string | AttributeApplyOptions, options: AttributeApplyOptions = {}) => createAttributeDecorator('remove')(selector, nameOrOptions, options);
|
|
142
143
|
|
|
143
|
-
//
|
|
144
|
-
export function
|
|
145
|
-
return createAttributeDecorator(action)('
|
|
144
|
+
// This versions
|
|
145
|
+
export function applyAttributeThis(action: AttributeAction = 'update', options: AttributeApplyOptions = {}): MethodDecorator {
|
|
146
|
+
return createAttributeDecorator(action)('$this', options);
|
|
146
147
|
}
|
|
147
|
-
export const
|
|
148
|
-
export const
|
|
149
|
-
export const
|
|
148
|
+
export const setAttributeThis = (nameOrOptions: string | AttributeApplyOptions, options: AttributeApplyOptions = {}) => createAttributeDecorator('set')('$this', nameOrOptions, options);
|
|
149
|
+
export const updateAttributeThis = (nameOrOptions: string | AttributeApplyOptions, options: AttributeApplyOptions = {}) => createAttributeDecorator('update')('$this', nameOrOptions, options);
|
|
150
|
+
export const removeAttributeThis = (nameOrOptions?: string | AttributeApplyOptions, options: AttributeApplyOptions = {}) => createAttributeDecorator('remove')('$this', nameOrOptions, options);
|
|
150
151
|
|
|
151
152
|
export const findAllAttributeApplyMetadata = (target: any): Map<string | symbol, AttributeApplyMetadata> => {
|
|
152
153
|
const result = new Map<string | symbol, AttributeApplyMetadata>();
|
|
@@ -57,15 +57,16 @@ function createClassDecorator(action: ClassAction) {
|
|
|
57
57
|
targetEls.push(t);
|
|
58
58
|
};
|
|
59
59
|
|
|
60
|
-
if (selector === '
|
|
61
|
-
else if (selector === '
|
|
62
|
-
else if (selector === '
|
|
63
|
-
else if (selector === '
|
|
64
|
-
else if (selector === '
|
|
65
|
-
else if (selector === '
|
|
66
|
-
else if (selector === '
|
|
67
|
-
else if (selector === '
|
|
68
|
-
else if (selector === '
|
|
60
|
+
if (selector === '$this' || !selector) applyRoot(host);
|
|
61
|
+
else if (selector === '$host') applyRoot(hostSet.$host);
|
|
62
|
+
else if (selector === '$parentHost') applyRoot(hostSet.$parentHost);
|
|
63
|
+
else if (selector === '$appHost') applyRoot(hostSet.$appHost);
|
|
64
|
+
else if (selector === '$firstHost') applyRoot(hostSet.$firstHost);
|
|
65
|
+
else if (selector === '$lastHost') applyRoot(hostSet.$lastHost);
|
|
66
|
+
else if (selector === '$firstAppHost') applyRoot(hostSet.$firstAppHost);
|
|
67
|
+
else if (selector === '$lastAppHost') applyRoot(hostSet.$lastAppHost);
|
|
68
|
+
else if (selector === '$hosts') hostSet.$hosts.forEach(applyRoot);
|
|
69
|
+
else if (selector === '$appHosts') hostSet.$appHosts.forEach(applyRoot);
|
|
69
70
|
else {
|
|
70
71
|
const targetRoot = r === 'auto' ? (host.shadowRoot || host) : (r === 'shadow' ? host.shadowRoot : host);
|
|
71
72
|
if (targetRoot) {
|
|
@@ -150,15 +151,15 @@ export const addClass = (selector: string, classMapOrOptions?: string | { [class
|
|
|
150
151
|
export const removeClass = (selector: string, classMapOrOptions?: string | { [className: string]: (el: HTMLElement, value: any, helper: HelperHostSet & { $this: any }) => boolean } | ClassApplyOptions, options: ClassApplyOptions = {}) => createClassDecorator('remove')(selector, classMapOrOptions, options);
|
|
151
152
|
export const toggleClass = (selector: string, classMapOrOptions?: string | { [className: string]: (el: HTMLElement, value: any, helper: HelperHostSet & { $this: any }) => boolean } | ClassApplyOptions, options: ClassApplyOptions = {}) => createClassDecorator('toggle')(selector, classMapOrOptions, options);
|
|
152
153
|
|
|
153
|
-
//
|
|
154
|
-
export function
|
|
155
|
-
return createClassDecorator(action)('
|
|
154
|
+
// This versions
|
|
155
|
+
export function applyClassThis(action: ClassAction = 'update', options: ClassApplyOptions = {}): MethodDecorator {
|
|
156
|
+
return createClassDecorator(action)('$this', options);
|
|
156
157
|
}
|
|
157
|
-
export const
|
|
158
|
-
export const
|
|
159
|
-
export const
|
|
160
|
-
export const
|
|
161
|
-
export const
|
|
158
|
+
export const setClassThis = (classMapOrOptions?: string | { [className: string]: (el: HTMLElement, value: any, helper: HelperHostSet & { $this: any }) => boolean } | ClassApplyOptions, options: ClassApplyOptions = {}) => createClassDecorator('set')('$this', classMapOrOptions, options);
|
|
159
|
+
export const updateClassThis = (classMapOrOptions?: string | { [className: string]: (el: HTMLElement, value: any, helper: HelperHostSet & { $this: any }) => boolean } | ClassApplyOptions, options: ClassApplyOptions = {}) => createClassDecorator('update')('$this', classMapOrOptions, options);
|
|
160
|
+
export const addClassThis = (classMapOrOptions?: string | { [className: string]: (el: HTMLElement, value: any, helper: HelperHostSet & { $this: any }) => boolean } | ClassApplyOptions, options: ClassApplyOptions = {}) => createClassDecorator('add')('$this', classMapOrOptions, options);
|
|
161
|
+
export const removeClassThis = (classMapOrOptions?: string | { [className: string]: (el: HTMLElement, value: any, helper: HelperHostSet & { $this: any }) => boolean } | ClassApplyOptions, options: ClassApplyOptions = {}) => createClassDecorator('remove')('$this', classMapOrOptions, options);
|
|
162
|
+
export const toggleClassThis = (classMapOrOptions?: string | { [className: string]: (el: HTMLElement, value: any, helper: HelperHostSet & { $this: any }) => boolean } | ClassApplyOptions, options: ClassApplyOptions = {}) => createClassDecorator('toggle')('$this', classMapOrOptions, options);
|
|
162
163
|
|
|
163
164
|
export const findAllClassMetadata = (target: any): Map<string | symbol, ClassApplyMetadata> => {
|
|
164
165
|
const result = new Map<string | symbol, ClassApplyMetadata>();
|
|
@@ -105,11 +105,12 @@ export function applyNode(selector: string, options: ApplyNodeOptions = { positi
|
|
|
105
105
|
return t;
|
|
106
106
|
};
|
|
107
107
|
|
|
108
|
-
if (selector === '
|
|
109
|
-
if (selector === '
|
|
110
|
-
if (selector === '
|
|
111
|
-
if (selector === '
|
|
112
|
-
if (selector === '
|
|
108
|
+
if (selector === '$this') return applyRoot(this);
|
|
109
|
+
if (selector === '$host') return applyRoot(hostSet.$host);
|
|
110
|
+
if (selector === '$parentHost') return applyRoot(hostSet.$parentHost);
|
|
111
|
+
if (selector === '$appHost') return applyRoot(hostSet.$appHost);
|
|
112
|
+
if (selector === '$firstHost') return applyRoot(hostSet.$firstHost);
|
|
113
|
+
if (selector === '$lastHost') return applyRoot(hostSet.$lastHost);
|
|
113
114
|
|
|
114
115
|
const targetRoot = applyRoot(this);
|
|
115
116
|
return targetRoot ? targetRoot.querySelector(selector) : null;
|
|
@@ -157,28 +158,28 @@ export const findAllApplyNodeMetadata = (target: any): Map<string | symbol, Appl
|
|
|
157
158
|
return result;
|
|
158
159
|
};
|
|
159
160
|
|
|
160
|
-
export function
|
|
161
|
-
export function
|
|
162
|
-
export function
|
|
163
|
-
if (propertyKey !== undefined) return applyNode('
|
|
161
|
+
export function applyNodeThis(options: ApplyNodeOptions): MethodDecorator;
|
|
162
|
+
export function applyNodeThis(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;
|
|
163
|
+
export function applyNodeThis(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {
|
|
164
|
+
if (propertyKey !== undefined) return applyNode('$this', { position: 'beforeEnd' })(targetOrOptions, propertyKey, descriptor);
|
|
164
165
|
const opt = targetOrOptions || {};
|
|
165
|
-
return applyNode('
|
|
166
|
+
return applyNode('$this', { position: 'beforeEnd', ...opt });
|
|
166
167
|
}
|
|
167
168
|
|
|
168
|
-
export function
|
|
169
|
-
export function
|
|
170
|
-
export function
|
|
171
|
-
if (propertyKey !== undefined) return applyNode('
|
|
169
|
+
export function applyReplaceChildrenNodeThis(options: ApplyNodeOptions): MethodDecorator;
|
|
170
|
+
export function applyReplaceChildrenNodeThis(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;
|
|
171
|
+
export function applyReplaceChildrenNodeThis(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {
|
|
172
|
+
if (propertyKey !== undefined) return applyNode('$this', { position: 'replaceChildren' })(targetOrOptions, propertyKey, descriptor);
|
|
172
173
|
const opt = targetOrOptions || {};
|
|
173
|
-
return applyNode('
|
|
174
|
+
return applyNode('$this', { position: 'replaceChildren', ...opt });
|
|
174
175
|
}
|
|
175
176
|
|
|
176
|
-
export function
|
|
177
|
-
export function
|
|
178
|
-
export function
|
|
179
|
-
if (propertyKey !== undefined) return applyNode('
|
|
177
|
+
export function applyInnerHtmlNodeThis(options: ApplyNodeOptions): MethodDecorator;
|
|
178
|
+
export function applyInnerHtmlNodeThis(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;
|
|
179
|
+
export function applyInnerHtmlNodeThis(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {
|
|
180
|
+
if (propertyKey !== undefined) return applyNode('$this', { position: 'innerHtml' })(targetOrOptions, propertyKey, descriptor);
|
|
180
181
|
const opt = targetOrOptions || {};
|
|
181
|
-
return applyNode('
|
|
182
|
+
return applyNode('$this', { position: 'innerHtml', ...opt });
|
|
182
183
|
}
|
|
183
184
|
|
|
184
185
|
export function applyReplaceChildrenNode(selector: string, options: ApplyNodeOptions = {}): MethodDecorator {
|
|
@@ -38,7 +38,7 @@ function createStyleDecorator(action: StyleAction) {
|
|
|
38
38
|
if (resolvedValue !== undefined) {
|
|
39
39
|
const win = (this as any).ownerDocument?.defaultView || window;
|
|
40
40
|
const host = this as unknown as HTMLElement;
|
|
41
|
-
const hostSet = SwcUtils.getHelperAndHostSet(win, host);
|
|
41
|
+
const hostSet = { ...SwcUtils.getHelperAndHostSet(win, host), $this: this };
|
|
42
42
|
const r = options.root || 'auto';
|
|
43
43
|
const targetEls: HTMLElement[] = [];
|
|
44
44
|
|
|
@@ -47,15 +47,16 @@ function createStyleDecorator(action: StyleAction) {
|
|
|
47
47
|
targetEls.push(t);
|
|
48
48
|
};
|
|
49
49
|
|
|
50
|
-
if (selector === '
|
|
51
|
-
else if (selector === '
|
|
52
|
-
else if (selector === '
|
|
53
|
-
else if (selector === '
|
|
54
|
-
else if (selector === '
|
|
55
|
-
else if (selector === '
|
|
56
|
-
else if (selector === '
|
|
57
|
-
else if (selector === '
|
|
58
|
-
else if (selector === '
|
|
50
|
+
if (selector === '$this' || !selector) applyRoot(host);
|
|
51
|
+
else if (selector === '$host') applyRoot(hostSet.$host);
|
|
52
|
+
else if (selector === '$parentHost') applyRoot(hostSet.$parentHost);
|
|
53
|
+
else if (selector === '$appHost') applyRoot(hostSet.$appHost);
|
|
54
|
+
else if (selector === '$firstHost') applyRoot(hostSet.$firstHost);
|
|
55
|
+
else if (selector === '$lastHost') applyRoot(hostSet.$lastHost);
|
|
56
|
+
else if (selector === '$firstAppHost') applyRoot(hostSet.$firstAppHost);
|
|
57
|
+
else if (selector === '$lastAppHost') applyRoot(hostSet.$lastAppHost);
|
|
58
|
+
else if (selector === '$hosts') hostSet.$hosts.forEach(applyRoot);
|
|
59
|
+
else if (selector === '$appHosts') hostSet.$appHosts.forEach(applyRoot);
|
|
59
60
|
else {
|
|
60
61
|
const targetRoot = r === 'auto' ? (host.shadowRoot || host) : (r === 'shadow' ? host.shadowRoot : host);
|
|
61
62
|
if (targetRoot) {
|
|
@@ -122,13 +123,13 @@ export const setStyle = (selector: string, options: StyleApplyOptions = {}) => c
|
|
|
122
123
|
export const updateStyle = (selector: string, options: StyleApplyOptions = {}) => createStyleDecorator('update')(selector, options);
|
|
123
124
|
export const removeStyle = (selector: string, options: StyleApplyOptions = {}) => createStyleDecorator('remove')(selector, options);
|
|
124
125
|
|
|
125
|
-
//
|
|
126
|
-
export function
|
|
127
|
-
return createStyleDecorator(action)('
|
|
126
|
+
// This versions
|
|
127
|
+
export function applyStyleThis(action: StyleAction = 'update', options: StyleApplyOptions = {}): MethodDecorator {
|
|
128
|
+
return createStyleDecorator(action)('$this', options);
|
|
128
129
|
}
|
|
129
|
-
export const
|
|
130
|
-
export const
|
|
131
|
-
export const
|
|
130
|
+
export const setStyleThis = (options: StyleApplyOptions = {}) => createStyleDecorator('set')('$this', options);
|
|
131
|
+
export const updateStyleThis = (options: StyleApplyOptions = {}) => createStyleDecorator('update')('$this', options);
|
|
132
|
+
export const removeStyleThis = (options: StyleApplyOptions = {}) => createStyleDecorator('remove')('$this', options);
|
|
132
133
|
|
|
133
134
|
export const findAllStyleMetadata = (target: any): Map<string | symbol, StyleApplyMetadata> => {
|
|
134
135
|
const result = new Map<string | symbol, StyleApplyMetadata>();
|
|
@@ -77,20 +77,21 @@ export const resolveTargetEls = (inst: any, selector: string, options: Attribute
|
|
|
77
77
|
}
|
|
78
78
|
};
|
|
79
79
|
|
|
80
|
-
if (selector === '
|
|
80
|
+
if (selector === '$this' || !selector) {
|
|
81
81
|
applyRoot(inst);
|
|
82
|
-
} else if (selector === '
|
|
82
|
+
} else if (selector === '$window') {
|
|
83
83
|
results.push(currentWin);
|
|
84
|
-
} else if (selector === '
|
|
84
|
+
} else if (selector === '$document') {
|
|
85
85
|
results.push(currentWin.document);
|
|
86
86
|
} else {
|
|
87
87
|
const hostSet = SwcUtils.getHostSet(inst);
|
|
88
|
-
if (selector === '
|
|
89
|
-
else if (selector === '
|
|
90
|
-
else if (selector === '
|
|
91
|
-
else if (selector === '
|
|
92
|
-
else if (selector === '
|
|
93
|
-
else if (selector === '
|
|
88
|
+
if (selector === '$host') applyRoot(hostSet.$host);
|
|
89
|
+
else if (selector === '$parentHost') applyRoot(hostSet.$parentHost);
|
|
90
|
+
else if (selector === '$appHost') applyRoot(hostSet.$appHost as any);
|
|
91
|
+
else if (selector === '$firstHost') applyRoot(hostSet.$firstHost);
|
|
92
|
+
else if (selector === '$lastHost') applyRoot(hostSet.$lastHost);
|
|
93
|
+
else if (selector === '$firstAppHost') applyRoot(hostSet.$firstAppHost as any);
|
|
94
|
+
else if (selector === '$lastAppHost') applyRoot(hostSet.$lastAppHost as any);
|
|
94
95
|
else {
|
|
95
96
|
if (r === 'shadow') {
|
|
96
97
|
const found = inst.shadowRoot?.querySelectorAll(selector);
|
|
@@ -189,29 +190,29 @@ export function attribute(selector: string, options: AttributeFieldOptions = {})
|
|
|
189
190
|
}
|
|
190
191
|
|
|
191
192
|
/**
|
|
192
|
-
* @
|
|
193
|
+
* @attributeThis decorator to sync a field value with the $this element's attribute.
|
|
193
194
|
*/
|
|
194
|
-
export function
|
|
195
|
-
export function
|
|
196
|
-
export function
|
|
197
|
-
export function
|
|
198
|
-
export function
|
|
195
|
+
export function attributeThis(target: Object, propertyKey: string | symbol): void;
|
|
196
|
+
export function attributeThis(options: AttributeFieldOptions): PropertyDecorator;
|
|
197
|
+
export function attributeThis(attrName: string): PropertyDecorator;
|
|
198
|
+
export function attributeThis(attrName: string, options: AttributeFieldOptions): PropertyDecorator;
|
|
199
|
+
export function attributeThis(targetOrAttrOrOptions?: any, propertyKeyOrOptions?: any): any {
|
|
199
200
|
if (propertyKeyOrOptions !== undefined && (typeof propertyKeyOrOptions === 'string' || typeof propertyKeyOrOptions === 'symbol')) {
|
|
200
|
-
return attribute('
|
|
201
|
+
return attribute('$this', { name: String(propertyKeyOrOptions) })(targetOrAttrOrOptions, propertyKeyOrOptions);
|
|
201
202
|
}
|
|
202
203
|
|
|
203
204
|
if (typeof targetOrAttrOrOptions === 'string') {
|
|
204
205
|
const attrName = targetOrAttrOrOptions;
|
|
205
206
|
const options = (typeof propertyKeyOrOptions === 'object' ? propertyKeyOrOptions : {}) as AttributeFieldOptions;
|
|
206
|
-
return attribute('
|
|
207
|
+
return attribute('$this', { ...options, name: attrName });
|
|
207
208
|
} else if (typeof targetOrAttrOrOptions === 'object') {
|
|
208
209
|
const options = targetOrAttrOrOptions as AttributeFieldOptions;
|
|
209
210
|
return (target: Object, propertyKey: string | symbol) => {
|
|
210
|
-
return attribute('
|
|
211
|
+
return attribute('$this', { ...options, name: String(propertyKey) })(target, propertyKey);
|
|
211
212
|
};
|
|
212
213
|
} else {
|
|
213
214
|
return (target: Object, propertyKey: string | symbol) => {
|
|
214
|
-
return attribute('
|
|
215
|
+
return attribute('$this', { name: String(propertyKey) })(target, propertyKey);
|
|
215
216
|
};
|
|
216
217
|
}
|
|
217
218
|
}
|
|
@@ -2,15 +2,15 @@ import { ReflectUtils } from '@dooboostore/core';
|
|
|
2
2
|
|
|
3
3
|
export const ON_ATTRIBUTE_CHANGED_METADATA_KEY = Symbol.for('simple-web-component:on-attribute-changed');
|
|
4
4
|
|
|
5
|
-
export interface
|
|
5
|
+
export interface ChangedAttributeThisOptions {
|
|
6
6
|
type?: typeof Number | typeof Boolean | typeof String;
|
|
7
7
|
while?: 'connected';
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
export interface
|
|
10
|
+
export interface ChangedAttributeThisMetadata {
|
|
11
11
|
attributeName: string;
|
|
12
12
|
propertyKey: string | symbol;
|
|
13
|
-
options:
|
|
13
|
+
options: ChangedAttributeThisOptions;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
const convertValue = (val: any, type: any): any => {
|
|
@@ -21,14 +21,12 @@ const convertValue = (val: any, type: any): any => {
|
|
|
21
21
|
};
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
|
-
* @
|
|
25
|
-
* Usage: @changedAttributeHost('data-product-id')
|
|
26
|
-
* @changedAttributeHost('count', { type: Number })
|
|
24
|
+
* @changedAttributeThis decorator - fires when any attribute on $this changes
|
|
27
25
|
*/
|
|
28
|
-
export function
|
|
26
|
+
export function changedAttributeThis(attributeName?: string, options: ChangedAttributeThisOptions = {}): MethodDecorator {
|
|
29
27
|
return (target: Object, propertyKey: string | symbol) => {
|
|
30
28
|
const constructor = target.constructor;
|
|
31
|
-
let metaList = ReflectUtils.getOwnMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, constructor) as
|
|
29
|
+
let metaList = ReflectUtils.getOwnMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, constructor) as ChangedAttributeThisMetadata[];
|
|
32
30
|
if (!metaList) {
|
|
33
31
|
metaList = [];
|
|
34
32
|
ReflectUtils.defineMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, metaList, constructor);
|
|
@@ -43,16 +41,16 @@ export function changedAttributeHost(attributeName?: string, options: ChangedAtt
|
|
|
43
41
|
};
|
|
44
42
|
}
|
|
45
43
|
|
|
46
|
-
export const getChangedAttributeMetadata = (target: any):
|
|
44
|
+
export const getChangedAttributeMetadata = (target: any): ChangedAttributeThisMetadata[] | undefined => {
|
|
47
45
|
const constructor = target instanceof Function ? target : target.constructor;
|
|
48
46
|
return ReflectUtils.getMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, constructor);
|
|
49
47
|
};
|
|
50
48
|
|
|
51
|
-
export const findAllAttributeChangedMetadata = (target: any): Map<string,
|
|
49
|
+
export const findAllAttributeChangedMetadata = (target: any): Map<string, ChangedAttributeThisMetadata[]> => {
|
|
52
50
|
const constructor = target instanceof Function ? target : target.constructor;
|
|
53
|
-
const metaList = ReflectUtils.findAllMetadata<
|
|
51
|
+
const metaList = ReflectUtils.findAllMetadata<ChangedAttributeThisMetadata[]>(ON_ATTRIBUTE_CHANGED_METADATA_KEY, constructor) || [];
|
|
54
52
|
|
|
55
|
-
const result = new Map<string,
|
|
53
|
+
const result = new Map<string, ChangedAttributeThisMetadata[]>();
|
|
56
54
|
metaList.forEach(meta => {
|
|
57
55
|
meta.forEach(item => {
|
|
58
56
|
if (!result.has(item.attributeName)) {
|
|
@@ -2,7 +2,7 @@ import {ReflectUtils, FunctionUtils, ActionExpression} from '@dooboostore/core';
|
|
|
2
2
|
import {getAddEventListenerMetadata} from './addEventListener';
|
|
3
3
|
import {ON_INITIALIZE_METADATA_KEY, ON_BEFORE_CONNECTED_METADATA_KEY, ON_AFTER_CONNECTED_METADATA_KEY, ON_BEFORE_DISCONNECTED_METADATA_KEY, ON_AFTER_DISCONNECTED_METADATA_KEY, ON_BEFORE_ADOPTED_METADATA_KEY, ON_AFTER_ADOPTED_METADATA_KEY, findAllLifecycleMetadata, getOnConnectedInnerHtmlMetadata} from './lifecycles';
|
|
4
4
|
import {getEmitCustomEventMetadataList} from './emitCustomEvent';
|
|
5
|
-
import {findAllAttributeChangedMetadata, convertAttributeValue} from './
|
|
5
|
+
import {findAllAttributeChangedMetadata, convertAttributeValue} from './changedAttributeThis';
|
|
6
6
|
import {findAllAttributeApplyMetadata} from './applyAttribute';
|
|
7
7
|
import {findAllAttributeMetadata, getAttributeValue} from './attribute';
|
|
8
8
|
import {getQueryMetadata} from './query';
|
|
@@ -54,7 +54,7 @@ export const ensureInit = (inst: any) => {
|
|
|
54
54
|
// ║ ║
|
|
55
55
|
// ║ 이유: ║
|
|
56
56
|
// ║ 1. TypeScript는 초기값이 있는 필드를 constructor에서 own property로 생성 ║
|
|
57
|
-
// ║ @
|
|
57
|
+
// ║ @attributeThis('id') myId: string = "default" → this.myId = "default" ║
|
|
58
58
|
// ║ ║
|
|
59
59
|
// ║ 2. JavaScript의 property lookup은 own property를 먼저 찾음 ║
|
|
60
60
|
// ║ - this.myId 접근 ║
|
|
@@ -92,7 +92,7 @@ export const ensureInit = (inst: any) => {
|
|
|
92
92
|
|
|
93
93
|
// Call constructor script if present
|
|
94
94
|
const hostSet = SwcUtils.getHostSet(inst);
|
|
95
|
-
const appHosts = SwcUtils.
|
|
95
|
+
const appHosts = SwcUtils.findAllAppHostsIncludingSelfDirect(inst);
|
|
96
96
|
inst._executeSwcScript?.('swc-on-constructor', hostSet);
|
|
97
97
|
|
|
98
98
|
// Call @onInitialize lifecycle methods
|
|
@@ -116,7 +116,7 @@ const handleGlobalSwcEvent = async (event: Event) => {
|
|
|
116
116
|
if (!(node instanceof HTMLElement)) continue;
|
|
117
117
|
const script = node.getAttribute?.(attrName);
|
|
118
118
|
if (script && !getElementConfig(node)) {
|
|
119
|
-
const host: any = SwcUtils.
|
|
119
|
+
const host: any = SwcUtils.findNearestSwcHostIncludingSelf(node);
|
|
120
120
|
if (host && host.isConnected && typeof host.__swc_executeAttributeEvent === 'function') {
|
|
121
121
|
await host.__swc_executeAttributeEvent(node, attrName, script, event);
|
|
122
122
|
(event as any).__swc_handled = true;
|
|
@@ -166,7 +166,7 @@ const setupPrototype = (proto: any) => {
|
|
|
166
166
|
proto._resolveWindow = function (localConfig?: ElementConfig): Window {
|
|
167
167
|
ensureInit(this);
|
|
168
168
|
if (localConfig?.window) return localConfig.window;
|
|
169
|
-
const ancestors = SwcUtils.
|
|
169
|
+
const ancestors = SwcUtils.findAllSwcHostsIncludingSelf(this as any);
|
|
170
170
|
for (let i = ancestors.length - 1; i >= 0; i--) {
|
|
171
171
|
const aConf = getElementConfig(ancestors[i]);
|
|
172
172
|
if (aConf?.window) return aConf.window;
|
|
@@ -285,7 +285,7 @@ export const elementDefine =
|
|
|
285
285
|
}
|
|
286
286
|
|
|
287
287
|
const emitCustomEventList = getEmitCustomEventMetadataList(constructor) || [];
|
|
288
|
-
const emitHostCustomEventList = emitCustomEventList.filter(meta => meta.selector === '
|
|
288
|
+
const emitHostCustomEventList = emitCustomEventList.filter(meta => meta.selector === '$this' || meta.selector === '');
|
|
289
289
|
const addEventListenerList = getAddEventListenerMetadata(constructor) || [];
|
|
290
290
|
const attrChangeMap = findAllAttributeChangedMetadata(constructor);
|
|
291
291
|
const attributeList = findAllAttributeMetadata(constructor);
|
|
@@ -297,7 +297,7 @@ export const elementDefine =
|
|
|
297
297
|
const attributeApplyNames = Array.from(applyAttributeMap.values())
|
|
298
298
|
.map(it => it.options.name)
|
|
299
299
|
.filter(Boolean) as string[];
|
|
300
|
-
const hostAttributes = attributeList.filter(it => it.selector === '
|
|
300
|
+
const hostAttributes = attributeList.filter(it => it.selector === '$this').map(it => it.options.name || String(it.propertyKey));
|
|
301
301
|
// Get original static observedAttributes before they're overwritten by Object.defineProperty
|
|
302
302
|
const originalStaticObservedAttributes = (constructor.observedAttributes ?? []) as string[];
|
|
303
303
|
const mergedObservedAttributes = [...new Set([...(metadata.observedAttributes ?? []), ...originalStaticObservedAttributes, ...attrChangeMap.keys(), ...attributeApplyNames, ...hostAttributes, ...emitHostCustomEventList.map(it => (it.options as any).attributeName).filter(Boolean), ...swcLifecycleAttributes, ...swcOnEvents])];
|
|
@@ -402,7 +402,7 @@ export const elementDefine =
|
|
|
402
402
|
const nonDelegateListeners: typeof addEventListenerList = [];
|
|
403
403
|
|
|
404
404
|
addEventListenerList.forEach(meta => {
|
|
405
|
-
if (meta.options.delegate && meta.selector !== '
|
|
405
|
+
if (meta.options.delegate && meta.selector !== '$window' && meta.selector !== '$document' && meta.selector !== '$host' && meta.selector !== '$appHost' && meta.selector !== '$firstHost' && meta.selector !== '$lastHost' && meta.selector !== '$firstAppHost' && meta.selector !== '$lastAppHost' && meta.selector !== '$hosts' && meta.selector !== '$appHosts' && meta.selector !== '$this' && meta.selector !== '') {
|
|
406
406
|
delegateListeners.push(meta);
|
|
407
407
|
} else {
|
|
408
408
|
nonDelegateListeners.push(meta);
|
|
@@ -482,17 +482,18 @@ export const elementDefine =
|
|
|
482
482
|
}
|
|
483
483
|
};
|
|
484
484
|
|
|
485
|
-
if (selector === '
|
|
486
|
-
else if (selector === '
|
|
487
|
-
else if (selector === '
|
|
488
|
-
else if (selector === '
|
|
489
|
-
else if (selector === '
|
|
490
|
-
else if (selector === '
|
|
491
|
-
else if (selector === '
|
|
492
|
-
else if (selector === '
|
|
493
|
-
else if (selector === '
|
|
494
|
-
else if (selector === '
|
|
495
|
-
else if (selector === '
|
|
485
|
+
if (selector === '$window') bindTargets.push(currentWin);
|
|
486
|
+
else if (selector === '$document') bindTargets.push(currentWin.document);
|
|
487
|
+
else if (selector === '$host') applyRootOption(helperHostSet.$host);
|
|
488
|
+
else if (selector === '$parentHost') applyRootOption(helperHostSet.$parentHost);
|
|
489
|
+
else if (selector === '$appHost') applyRootOption(helperHostSet.$appHost);
|
|
490
|
+
else if (selector === '$firstHost') applyRootOption(helperHostSet.$firstHost);
|
|
491
|
+
else if (selector === '$lastHost') applyRootOption(helperHostSet.$lastHost);
|
|
492
|
+
else if (selector === '$firstAppHost') applyRootOption(helperHostSet.$firstAppHost);
|
|
493
|
+
else if (selector === '$lastAppHost') applyRootOption(helperHostSet.$lastAppHost);
|
|
494
|
+
else if (selector === '$hosts') helperHostSet.$hosts.forEach(applyRootOption);
|
|
495
|
+
else if (selector === '$appHosts') helperHostSet.$appHosts.forEach(applyRootOption);
|
|
496
|
+
else if (selector === '$this' || !selector) applyRootOption(this);
|
|
496
497
|
else {
|
|
497
498
|
const searchRoots: (HTMLElement | ShadowRoot)[] = [];
|
|
498
499
|
if (r === 'auto') searchRoots.push(this.shadowRoot || (this as any));
|
|
@@ -541,7 +542,7 @@ export const elementDefine =
|
|
|
541
542
|
(this as any)._executeSwcScript('swc-on-after-connected', helperHostSet);
|
|
542
543
|
(this as any).__swc_connected = true;
|
|
543
544
|
|
|
544
|
-
// Trigger @
|
|
545
|
+
// Trigger @changedAttributeThis with while: 'connected'
|
|
545
546
|
for (let [name, metaList] of Array.from(attrChangeMap)) {
|
|
546
547
|
for (const meta of metaList) {
|
|
547
548
|
if (meta.options.while === 'connected') {
|
|
@@ -60,25 +60,27 @@ export function emitCustomEvent(selectorOrTarget: string, type: string, options:
|
|
|
60
60
|
const currentWin = (this as any)._resolveWindow?.(conf) || ((typeof window !== 'undefined' ? window : undefined) as Window);
|
|
61
61
|
|
|
62
62
|
const eventTargets: EventTarget[] = [];
|
|
63
|
-
if (selectorOrTarget === '
|
|
64
|
-
else if (selectorOrTarget === '
|
|
65
|
-
else if (selectorOrTarget === '
|
|
63
|
+
if (selectorOrTarget === '$window') eventTargets.push(currentWin);
|
|
64
|
+
else if (selectorOrTarget === '$document') eventTargets.push(currentWin.document);
|
|
65
|
+
else if (selectorOrTarget === '$host') {
|
|
66
|
+
if (hostSet.$host) eventTargets.push(hostSet.$host);
|
|
67
|
+
} else if (selectorOrTarget === '$parentHost') {
|
|
66
68
|
if (hostSet.$parentHost) eventTargets.push(hostSet.$parentHost);
|
|
67
|
-
} else if (selectorOrTarget === '
|
|
69
|
+
} else if (selectorOrTarget === '$appHost') {
|
|
68
70
|
if (hostSet.$appHost) eventTargets.push(hostSet.$appHost);
|
|
69
|
-
} else if (selectorOrTarget === '
|
|
71
|
+
} else if (selectorOrTarget === '$firstHost') {
|
|
70
72
|
if (hostSet.$firstHost) eventTargets.push(hostSet.$firstHost);
|
|
71
|
-
} else if (selectorOrTarget === '
|
|
73
|
+
} else if (selectorOrTarget === '$lastHost') {
|
|
72
74
|
if (hostSet.$lastHost) eventTargets.push(hostSet.$lastHost);
|
|
73
|
-
} else if (selectorOrTarget === '
|
|
75
|
+
} else if (selectorOrTarget === '$firstAppHost') {
|
|
74
76
|
if (hostSet.$firstAppHost) eventTargets.push(hostSet.$firstAppHost);
|
|
75
|
-
} else if (selectorOrTarget === '
|
|
77
|
+
} else if (selectorOrTarget === '$lastAppHost') {
|
|
76
78
|
if (hostSet.$lastAppHost) eventTargets.push(hostSet.$lastAppHost);
|
|
77
|
-
} else if (selectorOrTarget === '
|
|
79
|
+
} else if (selectorOrTarget === '$hosts') {
|
|
78
80
|
hostSet.$hosts.forEach(h => eventTargets.push(h));
|
|
79
|
-
} else if (selectorOrTarget === '
|
|
81
|
+
} else if (selectorOrTarget === '$appHosts') {
|
|
80
82
|
hostSet.$appHosts.forEach(h => eventTargets.push(h));
|
|
81
|
-
} else if (selectorOrTarget === '
|
|
83
|
+
} else if (selectorOrTarget === '$this' || !selectorOrTarget) {
|
|
82
84
|
eventTargets.push(this as any);
|
|
83
85
|
} else {
|
|
84
86
|
const r = fullOptions.root || 'auto';
|
|
@@ -121,27 +123,20 @@ export const getEmitCustomEventMetadataList = (target: any): EmitCustomEventMeta
|
|
|
121
123
|
};
|
|
122
124
|
|
|
123
125
|
/**
|
|
124
|
-
* @
|
|
125
|
-
* Usage: @emitCustomEventHost('navigate') // default attributeName: 'on-emit-navigate'
|
|
126
|
-
* Usage: @emitCustomEventHost('navigate', { attributeName: 'on-navigate' })
|
|
127
|
-
*
|
|
128
|
-
* The attributeName option is used to automatically observe attributes for this event.
|
|
129
|
-
* For example, { attributeName: 'on-navigate' } will add 'on-navigate' to observedAttributes.
|
|
126
|
+
* @emitCustomEventThis decorator - simplified version of @emitCustomEvent for $this selector
|
|
130
127
|
*/
|
|
131
|
-
export function
|
|
132
|
-
export function
|
|
133
|
-
export function
|
|
134
|
-
export function
|
|
128
|
+
export function emitCustomEventThis(type: string, options: EmitCustomEventBaseOptions & SwcQueryOptions & { attributeName?: string }): MethodDecorator ;
|
|
129
|
+
export function emitCustomEventThis(type: string, attributeName: string): MethodDecorator ;
|
|
130
|
+
export function emitCustomEventThis(type: string): MethodDecorator;
|
|
131
|
+
export function emitCustomEventThis(type: string, optionsOrAttributeaName?: string | (EmitCustomEventBaseOptions & SwcQueryOptions & { attributeName?: string })): MethodDecorator {
|
|
135
132
|
if (optionsOrAttributeaName && typeof optionsOrAttributeaName === 'string') {
|
|
136
|
-
return
|
|
133
|
+
return emitCustomEventThis(type, {attributeName: optionsOrAttributeaName});
|
|
137
134
|
} else if (optionsOrAttributeaName && typeof optionsOrAttributeaName === 'object') {
|
|
138
135
|
if (!optionsOrAttributeaName.attributeName) {
|
|
139
136
|
optionsOrAttributeaName.attributeName = `on-emit-${type}`;
|
|
140
137
|
}
|
|
141
|
-
return emitCustomEvent('
|
|
138
|
+
return emitCustomEvent('$this', type, optionsOrAttributeaName);
|
|
142
139
|
} else {
|
|
143
|
-
return emitCustomEvent('
|
|
140
|
+
return emitCustomEvent('$this', type, {attributeName: `on-emit-${type}`});
|
|
144
141
|
}
|
|
145
|
-
|
|
146
|
-
|
|
147
142
|
}
|
package/src/decorators/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export * from './addEventListener';
|
|
2
2
|
export * from './attribute';
|
|
3
3
|
export * from './elementDefine';
|
|
4
|
-
export * from './
|
|
4
|
+
export * from './changedAttributeThis';
|
|
5
5
|
export * from './emitCustomEvent';
|
|
6
6
|
export * from './applyNode';
|
|
7
7
|
export * from './lifecycles';
|