@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.
Files changed (136) hide show
  1. package/README.md +21 -21
  2. package/dist/cjs/decorators/addEventListener.js +12 -4
  3. package/dist/cjs/decorators/addEventListener.js.map +2 -2
  4. package/dist/cjs/decorators/applyAttribute.js +19 -18
  5. package/dist/cjs/decorators/applyAttribute.js.map +2 -2
  6. package/dist/cjs/decorators/applyClass.js +23 -22
  7. package/dist/cjs/decorators/applyClass.js.map +2 -2
  8. package/dist/cjs/decorators/applyNode.js +18 -17
  9. package/dist/cjs/decorators/applyNode.js.map +2 -2
  10. package/dist/cjs/decorators/applyStyle.js +20 -19
  11. package/dist/cjs/decorators/applyStyle.js.map +2 -2
  12. package/dist/cjs/decorators/attribute.js +16 -15
  13. package/dist/cjs/decorators/attribute.js.map +2 -2
  14. package/dist/cjs/decorators/{changedAttributeHost.js → changedAttributeThis.js} +6 -6
  15. package/dist/cjs/decorators/changedAttributeThis.js.map +7 -0
  16. package/dist/cjs/decorators/elementDefine.js +21 -20
  17. package/dist/cjs/decorators/elementDefine.js.map +2 -2
  18. package/dist/cjs/decorators/emitCustomEvent.js +18 -16
  19. package/dist/cjs/decorators/emitCustomEvent.js.map +2 -2
  20. package/dist/cjs/decorators/index.js +1 -1
  21. package/dist/cjs/decorators/index.js.map +1 -1
  22. package/dist/cjs/decorators/query.js +38 -60
  23. package/dist/cjs/decorators/query.js.map +2 -2
  24. package/dist/cjs/decorators/queryAll.js +31 -63
  25. package/dist/cjs/decorators/queryAll.js.map +2 -2
  26. package/dist/cjs/decorators/setProperty.js +13 -12
  27. package/dist/cjs/decorators/setProperty.js.map +2 -2
  28. package/dist/cjs/elements/SwcAsync.js +6 -6
  29. package/dist/cjs/elements/SwcAsync.js.map +1 -1
  30. package/dist/cjs/elements/SwcChoose.js +5 -5
  31. package/dist/cjs/elements/SwcChoose.js.map +1 -1
  32. package/dist/cjs/elements/SwcIf.js +6 -6
  33. package/dist/cjs/elements/SwcIf.js.map +1 -1
  34. package/dist/cjs/elements/SwcLoop.js +5 -5
  35. package/dist/cjs/elements/SwcLoop.js.map +1 -1
  36. package/dist/cjs/elements/register.js +18 -18
  37. package/dist/cjs/elements/register.js.map +1 -1
  38. package/dist/cjs/types.js.map +1 -1
  39. package/dist/cjs/utils/Utils.js +13 -13
  40. package/dist/cjs/utils/Utils.js.map +2 -2
  41. package/dist/esm/decorators/addEventListener.js +12 -4
  42. package/dist/esm/decorators/addEventListener.js.map +2 -2
  43. package/dist/esm/decorators/applyAttribute.js +19 -18
  44. package/dist/esm/decorators/applyAttribute.js.map +2 -2
  45. package/dist/esm/decorators/applyClass.js +23 -22
  46. package/dist/esm/decorators/applyClass.js.map +2 -2
  47. package/dist/esm/decorators/applyNode.js +18 -17
  48. package/dist/esm/decorators/applyNode.js.map +2 -2
  49. package/dist/esm/decorators/applyStyle.js +20 -19
  50. package/dist/esm/decorators/applyStyle.js.map +2 -2
  51. package/dist/esm/decorators/attribute.js +16 -15
  52. package/dist/esm/decorators/attribute.js.map +2 -2
  53. package/dist/esm/decorators/{changedAttributeHost.js → changedAttributeThis.js} +3 -3
  54. package/dist/esm/decorators/changedAttributeThis.js.map +7 -0
  55. package/dist/esm/decorators/elementDefine.js +19 -18
  56. package/dist/esm/decorators/elementDefine.js.map +2 -2
  57. package/dist/esm/decorators/emitCustomEvent.js +18 -16
  58. package/dist/esm/decorators/emitCustomEvent.js.map +2 -2
  59. package/dist/esm/decorators/index.js +1 -1
  60. package/dist/esm/decorators/index.js.map +1 -1
  61. package/dist/esm/decorators/query.js +38 -60
  62. package/dist/esm/decorators/query.js.map +2 -2
  63. package/dist/esm/decorators/queryAll.js +31 -63
  64. package/dist/esm/decorators/queryAll.js.map +2 -2
  65. package/dist/esm/decorators/setProperty.js +13 -12
  66. package/dist/esm/decorators/setProperty.js.map +2 -2
  67. package/dist/esm/elements/SwcAsync.js +7 -7
  68. package/dist/esm/elements/SwcAsync.js.map +1 -1
  69. package/dist/esm/elements/SwcChoose.js +6 -6
  70. package/dist/esm/elements/SwcChoose.js.map +1 -1
  71. package/dist/esm/elements/SwcIf.js +7 -7
  72. package/dist/esm/elements/SwcIf.js.map +1 -1
  73. package/dist/esm/elements/SwcLoop.js +6 -6
  74. package/dist/esm/elements/SwcLoop.js.map +1 -1
  75. package/dist/esm/elements/register.js +19 -19
  76. package/dist/esm/elements/register.js.map +1 -1
  77. package/dist/esm/types.js.map +1 -1
  78. package/dist/esm/utils/Utils.js +13 -13
  79. package/dist/esm/utils/Utils.js.map +2 -2
  80. package/dist/esm-bundle/dooboostore-simple-web-component.esm.js +271 -308
  81. package/dist/esm-bundle/dooboostore-simple-web-component.esm.js.map +4 -4
  82. package/dist/types/decorators/addEventListener.d.ts +5 -7
  83. package/dist/types/decorators/addEventListener.d.ts.map +1 -1
  84. package/dist/types/decorators/applyAttribute.d.ts +4 -4
  85. package/dist/types/decorators/applyAttribute.d.ts.map +1 -1
  86. package/dist/types/decorators/applyClass.d.ts +6 -6
  87. package/dist/types/decorators/applyClass.d.ts.map +1 -1
  88. package/dist/types/decorators/applyNode.d.ts +6 -6
  89. package/dist/types/decorators/applyNode.d.ts.map +1 -1
  90. package/dist/types/decorators/applyStyle.d.ts +4 -4
  91. package/dist/types/decorators/applyStyle.d.ts.map +1 -1
  92. package/dist/types/decorators/attribute.d.ts +5 -5
  93. package/dist/types/decorators/attribute.d.ts.map +1 -1
  94. package/dist/types/decorators/changedAttributeThis.d.ts +18 -0
  95. package/dist/types/decorators/changedAttributeThis.d.ts.map +1 -0
  96. package/dist/types/decorators/elementDefine.d.ts.map +1 -1
  97. package/dist/types/decorators/emitCustomEvent.d.ts +4 -9
  98. package/dist/types/decorators/emitCustomEvent.d.ts.map +1 -1
  99. package/dist/types/decorators/index.d.ts +1 -1
  100. package/dist/types/decorators/query.d.ts +17 -63
  101. package/dist/types/decorators/query.d.ts.map +1 -1
  102. package/dist/types/decorators/queryAll.d.ts +6 -63
  103. package/dist/types/decorators/queryAll.d.ts.map +1 -1
  104. package/dist/types/decorators/setProperty.d.ts +1 -1
  105. package/dist/types/decorators/setProperty.d.ts.map +1 -1
  106. package/dist/types/types.d.ts +2 -2
  107. package/dist/types/types.d.ts.map +1 -1
  108. package/dist/types/utils/Utils.d.ts +7 -7
  109. package/dist/types/utils/Utils.d.ts.map +1 -1
  110. package/dist/umd-bundle/dooboostore-simple-web-component.umd.js +271 -308
  111. package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +4 -4
  112. package/package.json +4 -4
  113. package/src/decorators/addEventListener.ts +11 -9
  114. package/src/decorators/applyAttribute.ts +16 -15
  115. package/src/decorators/applyClass.ts +18 -17
  116. package/src/decorators/applyNode.ts +21 -20
  117. package/src/decorators/applyStyle.ts +17 -16
  118. package/src/decorators/attribute.ts +20 -19
  119. package/src/decorators/{changedAttributeHost.ts → changedAttributeThis.ts} +10 -12
  120. package/src/decorators/elementDefine.ts +21 -20
  121. package/src/decorators/emitCustomEvent.ts +21 -26
  122. package/src/decorators/index.ts +1 -1
  123. package/src/decorators/query.ts +51 -124
  124. package/src/decorators/queryAll.ts +30 -127
  125. package/src/decorators/setProperty.ts +12 -11
  126. package/src/elements/SwcAsync.ts +7 -7
  127. package/src/elements/SwcChoose.ts +6 -6
  128. package/src/elements/SwcIf.ts +8 -8
  129. package/src/elements/SwcLoop.ts +6 -6
  130. package/src/elements/register.ts +20 -20
  131. package/src/types.ts +5 -5
  132. package/src/utils/Utils.ts +17 -18
  133. package/dist/cjs/decorators/changedAttributeHost.js.map +0 -7
  134. package/dist/esm/decorators/changedAttributeHost.js.map +0 -7
  135. package/dist/types/decorators/changedAttributeHost.d.ts +0 -20
  136. 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.35",
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-web": "1.0.10"
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
- * @addEventListenerHost decorator - simplified version of @addEventListener for :host selector
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 addEventListenerHost(type: string, options?: AddEventListenerBaseOptions & SwcQueryOptions): MethodDecorator {
55
- return addEventListener(':host', type, options);
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 :appHost selector
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(':appHost', type, options);
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 === ':parentHost') applyRoot(hostSet.$parentHost);
65
- else if (selector === ':appHost') applyRoot(hostSet.$appHost);
66
- else if (selector === ':firstHost') applyRoot(hostSet.$firstHost);
67
- else if (selector === ':lastHost') applyRoot(hostSet.$lastHost);
68
- else if (selector === ':firstAppHost') applyRoot(hostSet.$firstAppHost);
69
- else if (selector === ':lastAppHost') applyRoot(hostSet.$lastAppHost);
70
- else if (selector === ':hosts') hostSet.$hosts.forEach(applyRoot);
71
- else if (selector === ':appHosts') hostSet.$appHosts.forEach(applyRoot);
72
- else if (selector === ':host' || !selector) applyRoot(host);
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
- // Host versions
144
- export function applyAttributeHost(action: AttributeAction = 'update', options: AttributeApplyOptions = {}): MethodDecorator {
145
- return createAttributeDecorator(action)(':host', options);
144
+ // This versions
145
+ export function applyAttributeThis(action: AttributeAction = 'update', options: AttributeApplyOptions = {}): MethodDecorator {
146
+ return createAttributeDecorator(action)('$this', options);
146
147
  }
147
- export const setAttributeHost = (nameOrOptions: string | AttributeApplyOptions, options: AttributeApplyOptions = {}) => createAttributeDecorator('set')(':host', nameOrOptions, options);
148
- export const updateAttributeHost = (nameOrOptions: string | AttributeApplyOptions, options: AttributeApplyOptions = {}) => createAttributeDecorator('update')(':host', nameOrOptions, options);
149
- export const removeAttributeHost = (nameOrOptions?: string | AttributeApplyOptions, options: AttributeApplyOptions = {}) => createAttributeDecorator('remove')(':host', nameOrOptions, options);
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 === ':parentHost') applyRoot(hostSet.$parentHost);
61
- else if (selector === ':appHost') applyRoot(hostSet.$appHost);
62
- else if (selector === ':firstHost') applyRoot(hostSet.$firstHost);
63
- else if (selector === ':lastHost') applyRoot(hostSet.$lastHost);
64
- else if (selector === ':firstAppHost') applyRoot(hostSet.$firstAppHost);
65
- else if (selector === ':lastAppHost') applyRoot(hostSet.$lastAppHost);
66
- else if (selector === ':hosts') hostSet.$hosts.forEach(applyRoot);
67
- else if (selector === ':appHosts') hostSet.$appHosts.forEach(applyRoot);
68
- else if (selector === ':host' || !selector) applyRoot(host);
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
- // Host versions
154
- export function applyClassHost(action: ClassAction = 'update', options: ClassApplyOptions = {}): MethodDecorator {
155
- return createClassDecorator(action)(':host', options);
154
+ // This versions
155
+ export function applyClassThis(action: ClassAction = 'update', options: ClassApplyOptions = {}): MethodDecorator {
156
+ return createClassDecorator(action)('$this', options);
156
157
  }
157
- export const setClassHost = (classMapOrOptions?: string | { [className: string]: (el: HTMLElement, value: any, helper: HelperHostSet & { $this: any }) => boolean } | ClassApplyOptions, options: ClassApplyOptions = {}) => createClassDecorator('set')(':host', classMapOrOptions, options);
158
- export const updateClassHost = (classMapOrOptions?: string | { [className: string]: (el: HTMLElement, value: any, helper: HelperHostSet & { $this: any }) => boolean } | ClassApplyOptions, options: ClassApplyOptions = {}) => createClassDecorator('update')(':host', classMapOrOptions, options);
159
- export const addClassHost = (classMapOrOptions?: string | { [className: string]: (el: HTMLElement, value: any, helper: HelperHostSet & { $this: any }) => boolean } | ClassApplyOptions, options: ClassApplyOptions = {}) => createClassDecorator('add')(':host', classMapOrOptions, options);
160
- export const removeClassHost = (classMapOrOptions?: string | { [className: string]: (el: HTMLElement, value: any, helper: HelperHostSet & { $this: any }) => boolean } | ClassApplyOptions, options: ClassApplyOptions = {}) => createClassDecorator('remove')(':host', classMapOrOptions, options);
161
- export const toggleClassHost = (classMapOrOptions?: string | { [className: string]: (el: HTMLElement, value: any, helper: HelperHostSet & { $this: any }) => boolean } | ClassApplyOptions, options: ClassApplyOptions = {}) => createClassDecorator('toggle')(':host', classMapOrOptions, options);
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 === ':host') return applyRoot(this);
109
- if (selector === ':parentHost') return applyRoot(hostSet.$parentHost);
110
- if (selector === ':appHost') return applyRoot(hostSet.$appHost);
111
- if (selector === ':firstHost') return applyRoot(hostSet.$firstHost);
112
- if (selector === ':lastHost') return applyRoot(hostSet.$lastHost);
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 applyNodeHost(options: ApplyNodeOptions): MethodDecorator;
161
- export function applyNodeHost(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;
162
- export function applyNodeHost(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {
163
- if (propertyKey !== undefined) return applyNode(':host', { position: 'beforeEnd' })(targetOrOptions, propertyKey, descriptor);
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(':host', { position: 'beforeEnd', ...opt });
166
+ return applyNode('$this', { position: 'beforeEnd', ...opt });
166
167
  }
167
168
 
168
- export function applyReplaceChildrenNodeHost(options: ApplyNodeOptions): MethodDecorator;
169
- export function applyReplaceChildrenNodeHost(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;
170
- export function applyReplaceChildrenNodeHost(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {
171
- if (propertyKey !== undefined) return applyNode(':host', { position: 'replaceChildren' })(targetOrOptions, propertyKey, descriptor);
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(':host', { position: 'replaceChildren', ...opt });
174
+ return applyNode('$this', { position: 'replaceChildren', ...opt });
174
175
  }
175
176
 
176
- export function applyInnerHtmlNodeHost(options: ApplyNodeOptions): MethodDecorator;
177
- export function applyInnerHtmlNodeHost(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;
178
- export function applyInnerHtmlNodeHost(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {
179
- if (propertyKey !== undefined) return applyNode(':host', { position: 'innerHtml' })(targetOrOptions, propertyKey, descriptor);
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(':host', { position: 'innerHtml', ...opt });
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 === ':parentHost') applyRoot(hostSet.$parentHost);
51
- else if (selector === ':appHost') applyRoot(hostSet.$appHost);
52
- else if (selector === ':firstHost') applyRoot(hostSet.$firstHost);
53
- else if (selector === ':lastHost') applyRoot(hostSet.$lastHost);
54
- else if (selector === ':firstAppHost') applyRoot(hostSet.$firstAppHost);
55
- else if (selector === ':lastAppHost') applyRoot(hostSet.$lastAppHost);
56
- else if (selector === ':hosts') hostSet.$hosts.forEach(applyRoot);
57
- else if (selector === ':appHosts') hostSet.$appHosts.forEach(applyRoot);
58
- else if (selector === ':host' || !selector) applyRoot(host);
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
- // Host versions
126
- export function applyStyleHost(action: StyleAction = 'update', options: StyleApplyOptions = {}): MethodDecorator {
127
- return createStyleDecorator(action)(':host', options);
126
+ // This versions
127
+ export function applyStyleThis(action: StyleAction = 'update', options: StyleApplyOptions = {}): MethodDecorator {
128
+ return createStyleDecorator(action)('$this', options);
128
129
  }
129
- export const setStyleHost = (options: StyleApplyOptions = {}) => createStyleDecorator('set')(':host', options);
130
- export const updateStyleHost = (options: StyleApplyOptions = {}) => createStyleDecorator('update')(':host', options);
131
- export const removeStyleHost = (options: StyleApplyOptions = {}) => createStyleDecorator('remove')(':host', options);
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 === ':host' || !selector) {
80
+ if (selector === '$this' || !selector) {
81
81
  applyRoot(inst);
82
- } else if (selector === ':window') {
82
+ } else if (selector === '$window') {
83
83
  results.push(currentWin);
84
- } else if (selector === ':document') {
84
+ } else if (selector === '$document') {
85
85
  results.push(currentWin.document);
86
86
  } else {
87
87
  const hostSet = SwcUtils.getHostSet(inst);
88
- if (selector === ':parentHost') applyRoot(hostSet.$parentHost);
89
- else if (selector === ':appHost') applyRoot(hostSet.$appHost as any);
90
- else if (selector === ':firstHost') applyRoot(hostSet.$firstHost);
91
- else if (selector === ':lastHost') applyRoot(hostSet.$lastHost);
92
- else if (selector === ':firstAppHost') applyRoot(hostSet.$firstAppHost as any);
93
- else if (selector === ':lastAppHost') applyRoot(hostSet.$lastAppHost as any);
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
- * @attributeHost decorator to sync a field value with the :host element's attribute.
193
+ * @attributeThis decorator to sync a field value with the $this element's attribute.
193
194
  */
194
- export function attributeHost(target: Object, propertyKey: string | symbol): void;
195
- export function attributeHost(options: AttributeFieldOptions): PropertyDecorator;
196
- export function attributeHost(attrName: string): PropertyDecorator;
197
- export function attributeHost(attrName: string, options: AttributeFieldOptions): PropertyDecorator;
198
- export function attributeHost(targetOrAttrOrOptions?: any, propertyKeyOrOptions?: any): any {
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(':host', { name: String(propertyKeyOrOptions) })(targetOrAttrOrOptions, propertyKeyOrOptions);
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(':host', { ...options, name: attrName });
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(':host', { ...options, name: String(propertyKey) })(target, propertyKey);
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(':host', { name: String(propertyKey) })(target, propertyKey);
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 ChangedAttributeHostOptions {
5
+ export interface ChangedAttributeThisOptions {
6
6
  type?: typeof Number | typeof Boolean | typeof String;
7
7
  while?: 'connected';
8
8
  }
9
9
 
10
- export interface ChangedAttributeHostMetadata {
10
+ export interface ChangedAttributeThisMetadata {
11
11
  attributeName: string;
12
12
  propertyKey: string | symbol;
13
- options: ChangedAttributeHostOptions;
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
- * @changedAttributeHost decorator - fires when any attribute on :host changes
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 changedAttributeHost(attributeName?: string, options: ChangedAttributeHostOptions = {}): MethodDecorator {
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 ChangedAttributeHostMetadata[];
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): ChangedAttributeHostMetadata[] | undefined => {
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, ChangedAttributeHostMetadata[]> => {
49
+ export const findAllAttributeChangedMetadata = (target: any): Map<string, ChangedAttributeThisMetadata[]> => {
52
50
  const constructor = target instanceof Function ? target : target.constructor;
53
- const metaList = ReflectUtils.findAllMetadata<ChangedAttributeHostMetadata[]>(ON_ATTRIBUTE_CHANGED_METADATA_KEY, constructor) || [];
51
+ const metaList = ReflectUtils.findAllMetadata<ChangedAttributeThisMetadata[]>(ON_ATTRIBUTE_CHANGED_METADATA_KEY, constructor) || [];
54
52
 
55
- const result = new Map<string, ChangedAttributeHostMetadata[]>();
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 './changedAttributeHost';
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
- // ║ @attributeHost('id') myId: string = "default" → this.myId = "default" ║
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.findAllParentAppHostsDirect(inst);
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.findNearestSwcHost(node);
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.findAllSwcHosts(this as any);
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 === ':host' || 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 === ':host').map(it => it.options.name || String(it.propertyKey));
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 !== ':window' && meta.selector !== ':document' && meta.selector !== ':parentHost' && meta.selector !== ':appHost' && meta.selector !== ':firstHost' && meta.selector !== ':lastHost' && meta.selector !== ':firstAppHost' && meta.selector !== ':lastAppHost' && meta.selector !== ':hosts' && meta.selector !== ':appHosts' && meta.selector !== ':host' && 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 === ':window') bindTargets.push(currentWin);
486
- else if (selector === ':document') bindTargets.push(currentWin.document);
487
- else if (selector === ':parentHost') applyRootOption(helperHostSet.$parentHost);
488
- else if (selector === ':appHost') applyRootOption(helperHostSet.$appHost);
489
- else if (selector === ':firstHost') applyRootOption(helperHostSet.$firstHost);
490
- else if (selector === ':lastHost') applyRootOption(helperHostSet.$lastHost);
491
- else if (selector === ':firstAppHost') applyRootOption(helperHostSet.$firstAppHost);
492
- else if (selector === ':lastAppHost') applyRootOption(helperHostSet.$lastAppHost);
493
- else if (selector === ':hosts') helperHostSet.$hosts.forEach(applyRootOption);
494
- else if (selector === ':appHosts') helperHostSet.$appHosts.forEach(applyRootOption);
495
- else if (selector === ':host' || !selector) applyRootOption(this);
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 @changedAttributeHost with while: 'connected'
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 === ':window') eventTargets.push(currentWin);
64
- else if (selectorOrTarget === ':document') eventTargets.push(currentWin.document);
65
- else if (selectorOrTarget === ':parentHost') {
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 === ':appHost') {
69
+ } else if (selectorOrTarget === '$appHost') {
68
70
  if (hostSet.$appHost) eventTargets.push(hostSet.$appHost);
69
- } else if (selectorOrTarget === ':firstHost') {
71
+ } else if (selectorOrTarget === '$firstHost') {
70
72
  if (hostSet.$firstHost) eventTargets.push(hostSet.$firstHost);
71
- } else if (selectorOrTarget === ':lastHost') {
73
+ } else if (selectorOrTarget === '$lastHost') {
72
74
  if (hostSet.$lastHost) eventTargets.push(hostSet.$lastHost);
73
- } else if (selectorOrTarget === ':firstAppHost') {
75
+ } else if (selectorOrTarget === '$firstAppHost') {
74
76
  if (hostSet.$firstAppHost) eventTargets.push(hostSet.$firstAppHost);
75
- } else if (selectorOrTarget === ':lastAppHost') {
77
+ } else if (selectorOrTarget === '$lastAppHost') {
76
78
  if (hostSet.$lastAppHost) eventTargets.push(hostSet.$lastAppHost);
77
- } else if (selectorOrTarget === ':hosts') {
79
+ } else if (selectorOrTarget === '$hosts') {
78
80
  hostSet.$hosts.forEach(h => eventTargets.push(h));
79
- } else if (selectorOrTarget === ':appHosts') {
81
+ } else if (selectorOrTarget === '$appHosts') {
80
82
  hostSet.$appHosts.forEach(h => eventTargets.push(h));
81
- } else if (selectorOrTarget === ':host' || !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
- * @emitCustomEventHost decorator - simplified version of @emitCustomEvent for :host selector
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 emitCustomEventHost(type: string, options: EmitCustomEventBaseOptions & SwcQueryOptions & { attributeName?: string }): MethodDecorator ;
132
- export function emitCustomEventHost(type: string, attributeName: string): MethodDecorator ;
133
- export function emitCustomEventHost(type: string): MethodDecorator;
134
- export function emitCustomEventHost(type: string, optionsOrAttributeaName?: string | (EmitCustomEventBaseOptions & SwcQueryOptions & { attributeName?: string })): MethodDecorator {
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 emitCustomEventHost(type, {attributeName: optionsOrAttributeaName});
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(':host', type, optionsOrAttributeaName);
138
+ return emitCustomEvent('$this', type, optionsOrAttributeaName);
142
139
  } else {
143
- return emitCustomEvent(':host', type, {attributeName: `on-emit-${type}`});
140
+ return emitCustomEvent('$this', type, {attributeName: `on-emit-${type}`});
144
141
  }
145
-
146
-
147
142
  }
@@ -1,7 +1,7 @@
1
1
  export * from './addEventListener';
2
2
  export * from './attribute';
3
3
  export * from './elementDefine';
4
- export * from './changedAttributeHost';
4
+ export * from './changedAttributeThis';
5
5
  export * from './emitCustomEvent';
6
6
  export * from './applyNode';
7
7
  export * from './lifecycles';