@dooboostore/simple-web-component 1.0.21 → 1.0.22
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 +771 -95
- package/dist/cjs/decorators/addEventListener.js +4 -0
- package/dist/cjs/decorators/addEventListener.js.map +2 -2
- package/dist/cjs/decorators/{appendChild.js → applyNode.js} +25 -17
- package/dist/cjs/decorators/applyNode.js.map +7 -0
- package/dist/cjs/decorators/attribute.js +31 -10
- package/dist/cjs/decorators/attribute.js.map +3 -3
- package/dist/cjs/decorators/{changedAttribute.js → changedAttributeHost.js} +6 -6
- package/dist/cjs/decorators/changedAttributeHost.js.map +7 -0
- package/dist/cjs/decorators/classList.js +11 -1
- package/dist/cjs/decorators/classList.js.map +2 -2
- package/dist/cjs/decorators/elementDefine.js +106 -55
- package/dist/cjs/decorators/elementDefine.js.map +2 -2
- package/dist/cjs/decorators/emitCustomEvent.js +4 -3
- package/dist/cjs/decorators/emitCustomEvent.js.map +2 -2
- package/dist/cjs/decorators/index.js +2 -3
- package/dist/cjs/decorators/index.js.map +2 -2
- package/dist/cjs/decorators/lifecycles.js +4 -0
- package/dist/cjs/decorators/lifecycles.js.map +2 -2
- package/dist/cjs/decorators/query.js +5 -1
- package/dist/cjs/decorators/query.js.map +2 -2
- package/dist/cjs/decorators/queryAll.js +5 -1
- package/dist/cjs/decorators/queryAll.js.map +2 -2
- package/dist/cjs/decorators/setAttribute.js +5 -1
- package/dist/cjs/decorators/setAttribute.js.map +2 -2
- package/dist/cjs/elements/SwcAppEngine.js.map +2 -2
- package/dist/cjs/elements/SwcAppMixin.js.map +2 -2
- package/dist/cjs/elements/SwcAsync.js +2 -2
- package/dist/cjs/elements/SwcAsync.js.map +2 -2
- package/dist/cjs/elements/SwcChoose.js +2 -2
- package/dist/cjs/elements/SwcChoose.js.map +2 -2
- package/dist/cjs/elements/SwcIf.js +2 -2
- package/dist/cjs/elements/SwcIf.js.map +2 -2
- package/dist/cjs/elements/SwcLoop.js +2 -2
- package/dist/cjs/elements/SwcLoop.js.map +2 -2
- package/dist/cjs/elements/register.js +6 -5
- package/dist/cjs/elements/register.js.map +2 -2
- package/dist/cjs/index.js +6 -18
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs/types.js.map +2 -2
- package/dist/esm/decorators/addEventListener.js +4 -0
- package/dist/esm/decorators/addEventListener.js.map +2 -2
- package/dist/esm/decorators/{appendChild.js → applyNode.js} +22 -14
- package/dist/esm/decorators/applyNode.js.map +7 -0
- package/dist/esm/decorators/attribute.js +31 -10
- package/dist/esm/decorators/attribute.js.map +3 -3
- package/dist/esm/decorators/{changedAttribute.js → changedAttributeHost.js} +3 -3
- package/dist/esm/decorators/changedAttributeHost.js.map +7 -0
- package/dist/esm/decorators/classList.js +11 -1
- package/dist/esm/decorators/classList.js.map +2 -2
- package/dist/esm/decorators/elementDefine.js +106 -55
- package/dist/esm/decorators/elementDefine.js.map +2 -2
- package/dist/esm/decorators/emitCustomEvent.js +4 -3
- package/dist/esm/decorators/emitCustomEvent.js.map +2 -2
- package/dist/esm/decorators/index.js +2 -3
- package/dist/esm/decorators/index.js.map +2 -2
- package/dist/esm/decorators/lifecycles.js +4 -0
- package/dist/esm/decorators/lifecycles.js.map +2 -2
- package/dist/esm/decorators/query.js +5 -1
- package/dist/esm/decorators/query.js.map +2 -2
- package/dist/esm/decorators/queryAll.js +5 -1
- package/dist/esm/decorators/queryAll.js.map +2 -2
- package/dist/esm/decorators/setAttribute.js +5 -1
- package/dist/esm/decorators/setAttribute.js.map +2 -2
- package/dist/esm/elements/SwcAppEngine.js.map +2 -2
- package/dist/esm/elements/SwcAppMixin.js.map +2 -2
- package/dist/esm/elements/SwcAsync.js +2 -2
- package/dist/esm/elements/SwcAsync.js.map +2 -2
- package/dist/esm/elements/SwcChoose.js +2 -2
- package/dist/esm/elements/SwcChoose.js.map +2 -2
- package/dist/esm/elements/SwcIf.js +2 -2
- package/dist/esm/elements/SwcIf.js.map +2 -2
- package/dist/esm/elements/SwcLoop.js +2 -2
- package/dist/esm/elements/SwcLoop.js.map +2 -2
- package/dist/esm/elements/register.js +6 -5
- package/dist/esm/elements/register.js.map +2 -2
- package/dist/esm/index.js +6 -18
- package/dist/esm/index.js.map +2 -2
- package/dist/esm/types.js.map +2 -2
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js +195 -139
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js.map +4 -4
- package/dist/types/decorators/addEventListener.d.ts +6 -0
- package/dist/types/decorators/addEventListener.d.ts.map +1 -1
- package/dist/types/decorators/applyNode.d.ts +38 -0
- package/dist/types/decorators/applyNode.d.ts.map +1 -0
- package/dist/types/decorators/attribute.d.ts +6 -0
- package/dist/types/decorators/attribute.d.ts.map +1 -1
- package/dist/types/decorators/{changedAttribute.d.ts → changedAttributeHost.d.ts} +6 -2
- package/dist/types/decorators/changedAttributeHost.d.ts.map +1 -0
- package/dist/types/decorators/classList.d.ts +25 -0
- package/dist/types/decorators/classList.d.ts.map +1 -1
- package/dist/types/decorators/elementDefine.d.ts.map +1 -1
- package/dist/types/decorators/emitCustomEvent.d.ts +14 -2
- package/dist/types/decorators/emitCustomEvent.d.ts.map +1 -1
- package/dist/types/decorators/index.d.ts +2 -3
- package/dist/types/decorators/index.d.ts.map +1 -1
- package/dist/types/decorators/lifecycles.d.ts +2 -0
- package/dist/types/decorators/lifecycles.d.ts.map +1 -1
- package/dist/types/decorators/query.d.ts +6 -0
- package/dist/types/decorators/query.d.ts.map +1 -1
- package/dist/types/decorators/queryAll.d.ts +6 -0
- package/dist/types/decorators/queryAll.d.ts.map +1 -1
- package/dist/types/decorators/setAttribute.d.ts +5 -0
- package/dist/types/decorators/setAttribute.d.ts.map +1 -1
- package/dist/types/elements/SwcAppEngine.d.ts.map +1 -1
- package/dist/types/elements/SwcAppMixin.d.ts.map +1 -1
- package/dist/types/elements/register.d.ts +1 -1
- package/dist/types/elements/register.d.ts.map +1 -1
- package/dist/types/index.d.ts +3 -15
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/types.d.ts +2 -1
- package/dist/types/types.d.ts.map +1 -1
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js +195 -139
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +4 -4
- package/package.json +3 -3
- package/src/decorators/addEventListener.ts +9 -0
- package/src/decorators/applyNode.ts +127 -0
- package/src/decorators/attribute.ts +46 -12
- package/src/decorators/{changedAttribute.ts → changedAttributeHost.ts} +5 -1
- package/src/decorators/classList.ts +32 -0
- package/src/decorators/elementDefine.ts +130 -62
- package/src/decorators/emitCustomEvent.ts +13 -5
- package/src/decorators/index.ts +2 -3
- package/src/decorators/lifecycles.ts +3 -1
- package/src/decorators/query.ts +9 -0
- package/src/decorators/queryAll.ts +9 -0
- package/src/decorators/setAttribute.ts +8 -0
- package/src/elements/SwcAppEngine.ts +1 -0
- package/src/elements/SwcAppMixin.ts +2 -1
- package/src/elements/SwcAsync.ts +2 -2
- package/src/elements/SwcChoose.ts +2 -2
- package/src/elements/SwcIf.ts +2 -2
- package/src/elements/SwcLoop.ts +2 -2
- package/src/elements/register.ts +7 -5
- package/src/index.ts +8 -17
- package/src/types.ts +2 -1
- package/dist/cjs/decorators/appendChild.js.map +0 -7
- package/dist/cjs/decorators/changedAttribute.js.map +0 -7
- package/dist/cjs/decorators/replaceChildren.js +0 -79
- package/dist/cjs/decorators/replaceChildren.js.map +0 -7
- package/dist/esm/decorators/appendChild.js.map +0 -7
- package/dist/esm/decorators/changedAttribute.js.map +0 -7
- package/dist/esm/decorators/replaceChildren.js +0 -60
- package/dist/esm/decorators/replaceChildren.js.map +0 -7
- package/dist/types/decorators/appendChild.d.ts +0 -17
- package/dist/types/decorators/appendChild.d.ts.map +0 -1
- package/dist/types/decorators/changedAttribute.d.ts.map +0 -1
- package/dist/types/decorators/replaceChildren.d.ts +0 -9
- package/dist/types/decorators/replaceChildren.d.ts.map +0 -1
- package/src/decorators/appendChild.ts +0 -86
- package/src/decorators/replaceChildren.ts +0 -64
|
@@ -1119,7 +1119,7 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
1119
1119
|
var bundle_entry_exports = {};
|
|
1120
1120
|
__export(bundle_entry_exports, {
|
|
1121
1121
|
ADD_EVENT_LISTENER_METADATA_KEY: () => ADD_EVENT_LISTENER_METADATA_KEY,
|
|
1122
|
-
|
|
1122
|
+
APPLY_NODE_METADATA_KEY: () => APPLY_NODE_METADATA_KEY,
|
|
1123
1123
|
ATTRIBUTE_CHANGED_WILDCARD: () => ATTRIBUTE_CHANGED_WILDCARD,
|
|
1124
1124
|
ATTRIBUTE_METADATA_KEY: () => ATTRIBUTE_METADATA_KEY,
|
|
1125
1125
|
BROWSER_GLOBALS: () => BROWSER_GLOBALS,
|
|
@@ -1128,6 +1128,7 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
1128
1128
|
ELEMENT_CONFIG_KEY: () => ELEMENT_CONFIG_KEY,
|
|
1129
1129
|
EMIT_CUSTOM_EVENT_METADATA_KEY: () => EMIT_CUSTOM_EVENT_METADATA_KEY,
|
|
1130
1130
|
HTML_TAG_ENTRIES: () => HTML_TAG_ENTRIES,
|
|
1131
|
+
INNER_HTML_METADATA_KEY: () => INNER_HTML_METADATA_KEY,
|
|
1131
1132
|
InjectSituationType: () => InjectSituationType,
|
|
1132
1133
|
ON_ADD_EVENT_LISTENER_METADATA_KEY: () => ON_ADD_EVENT_LISTENER_METADATA_KEY,
|
|
1133
1134
|
ON_AFTER_ADOPTED_METADATA_KEY: () => ON_AFTER_ADOPTED_METADATA_KEY,
|
|
@@ -1137,38 +1138,42 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
1137
1138
|
ON_BEFORE_ADOPTED_METADATA_KEY: () => ON_BEFORE_ADOPTED_METADATA_KEY,
|
|
1138
1139
|
ON_BEFORE_CONNECTED_METADATA_KEY: () => ON_BEFORE_CONNECTED_METADATA_KEY,
|
|
1139
1140
|
ON_BEFORE_DISCONNECTED_METADATA_KEY: () => ON_BEFORE_DISCONNECTED_METADATA_KEY,
|
|
1141
|
+
ON_CONSTRUCTOR_METADATA_KEY: () => ON_CONSTRUCTOR_METADATA_KEY,
|
|
1140
1142
|
QUERY_ALL_METADATA_KEY: () => QUERY_ALL_METADATA_KEY,
|
|
1141
1143
|
QUERY_METADATA_KEY: () => QUERY_METADATA_KEY,
|
|
1142
|
-
REPLACE_CHILDREN_METADATA_KEY: () => REPLACE_CHILDREN_METADATA_KEY,
|
|
1143
1144
|
SET_ATTRIBUTE_METADATA_KEY: () => SET_ATTRIBUTE_METADATA_KEY,
|
|
1144
1145
|
STYLE_METADATA_KEY: () => STYLE_METADATA_KEY,
|
|
1145
1146
|
SWC_NOT_FOUND: () => SWC_NOT_FOUND,
|
|
1146
1147
|
SwcUtils: () => SwcUtils,
|
|
1147
1148
|
TemplateUtils: () => TemplateUtils,
|
|
1148
1149
|
addClassList: () => addClassList,
|
|
1150
|
+
addClassListHost: () => addClassListHost,
|
|
1149
1151
|
addEventListener: () => addEventListener,
|
|
1150
|
-
|
|
1152
|
+
addEventListenerHost: () => addEventListenerHost,
|
|
1153
|
+
applyNode: () => applyNode,
|
|
1154
|
+
applyNodeHost: () => applyNodeHost,
|
|
1151
1155
|
attribute: () => attribute,
|
|
1152
|
-
|
|
1156
|
+
attributeHost: () => attributeHost,
|
|
1157
|
+
changedAttributeHost: () => changedAttributeHost,
|
|
1153
1158
|
createElement: () => createElement,
|
|
1154
1159
|
elementDefine: () => elementDefine,
|
|
1155
1160
|
emitCustomEvent: () => emitCustomEvent,
|
|
1161
|
+
emitCustomEventHost: () => emitCustomEventHost,
|
|
1156
1162
|
ensureInit: () => ensureInit2,
|
|
1157
|
-
|
|
1163
|
+
findAllApplyNodeMetadata: () => findAllApplyNodeMetadata,
|
|
1158
1164
|
findAllAttributeChangedMetadata: () => findAllAttributeChangedMetadata,
|
|
1159
1165
|
findAllAttributeMetadata: () => findAllAttributeMetadata,
|
|
1160
1166
|
findAllClassListMetadata: () => findAllClassListMetadata,
|
|
1161
1167
|
findAllLifecycleMetadata: () => findAllLifecycleMetadata,
|
|
1162
|
-
findAllReplaceChildrenMetadata: () => findAllReplaceChildrenMetadata,
|
|
1163
1168
|
findAllSetAttributeMetadata: () => findAllSetAttributeMetadata,
|
|
1164
1169
|
findAllStyleMetadata: () => findAllStyleMetadata,
|
|
1165
1170
|
getAddEventListenerMetadata: () => getAddEventListenerMetadata,
|
|
1166
1171
|
getChangedAttributeMetadata: () => getChangedAttributeMetadata,
|
|
1167
1172
|
getElementConfig: () => getElementConfig,
|
|
1168
1173
|
getEmitCustomEventMetadataList: () => getEmitCustomEventMetadataList,
|
|
1174
|
+
getOnConnectedInnerHtmlMetadata: () => getOnConnectedInnerHtmlMetadata,
|
|
1169
1175
|
getQueryAllMetadata: () => getQueryAllMetadata,
|
|
1170
1176
|
getQueryMetadata: () => getQueryMetadata,
|
|
1171
|
-
getReplaceChildrenMetadata: () => getReplaceChildrenMetadata,
|
|
1172
1177
|
getSetAttributeMetadata: () => getSetAttributeMetadata,
|
|
1173
1178
|
htmlAElement: () => htmlAElement,
|
|
1174
1179
|
htmlArticleElement: () => htmlArticleElement,
|
|
@@ -1197,19 +1202,26 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
1197
1202
|
onBeforeDisconnected: () => onBeforeDisconnected,
|
|
1198
1203
|
onConnected: () => onConnected,
|
|
1199
1204
|
onConnectedInnerHtml: () => onConnectedInnerHtml,
|
|
1205
|
+
onConstructor: () => onConstructor,
|
|
1200
1206
|
onDisconnected: () => onDisconnected,
|
|
1201
1207
|
query: () => query,
|
|
1202
1208
|
queryAll: () => queryAll,
|
|
1209
|
+
queryAllHost: () => queryAllHost,
|
|
1210
|
+
queryHost: () => queryHost,
|
|
1203
1211
|
removeClassList: () => removeClassList,
|
|
1212
|
+
removeClassListHost: () => removeClassListHost,
|
|
1204
1213
|
removeStyle: () => removeStyle,
|
|
1205
|
-
replaceChildren: () => replaceChildren,
|
|
1206
1214
|
resolveTargetEls: () => resolveTargetEls,
|
|
1207
1215
|
setAttribute: () => setAttribute,
|
|
1216
|
+
setAttributeHost: () => setAttributeHost,
|
|
1208
1217
|
setClassList: () => setClassList,
|
|
1218
|
+
setClassListHost: () => setClassListHost,
|
|
1209
1219
|
setStyle: () => setStyle,
|
|
1210
1220
|
textNode: () => textNode,
|
|
1211
1221
|
toggleClassList: () => toggleClassList,
|
|
1222
|
+
toggleClassListHost: () => toggleClassListHost,
|
|
1212
1223
|
updateClassList: () => updateClassList,
|
|
1224
|
+
updateClassListHost: () => updateClassListHost,
|
|
1213
1225
|
updateStyle: () => updateStyle
|
|
1214
1226
|
});
|
|
1215
1227
|
var import_reflect_metadata2 = __toESM(require_Reflect(), 1);
|
|
@@ -5858,8 +5870,12 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
5858
5870
|
const constructor = target instanceof Function ? target : target.constructor;
|
|
5859
5871
|
return ReflectUtils.getMetadata(ADD_EVENT_LISTENER_METADATA_KEY, constructor);
|
|
5860
5872
|
};
|
|
5873
|
+
function addEventListenerHost(type, options) {
|
|
5874
|
+
return addEventListener(":host", type, options);
|
|
5875
|
+
}
|
|
5861
5876
|
|
|
5862
5877
|
// src/decorators/lifecycles.ts
|
|
5878
|
+
var ON_CONSTRUCTOR_METADATA_KEY = Symbol("simple-web-component:on-constructor");
|
|
5863
5879
|
var ON_BEFORE_CONNECTED_METADATA_KEY = Symbol("simple-web-component:on-before-connected");
|
|
5864
5880
|
var ON_AFTER_CONNECTED_METADATA_KEY = Symbol("simple-web-component:on-after-connected");
|
|
5865
5881
|
var ON_BEFORE_DISCONNECTED_METADATA_KEY = Symbol("simple-web-component:on-before-disconnected");
|
|
@@ -5879,6 +5895,7 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
5879
5895
|
list.push(propertyKey);
|
|
5880
5896
|
};
|
|
5881
5897
|
}
|
|
5898
|
+
var onConstructor = createLifecycleDecorator(ON_CONSTRUCTOR_METADATA_KEY);
|
|
5882
5899
|
var onBeforeConnected = createLifecycleDecorator(ON_BEFORE_CONNECTED_METADATA_KEY);
|
|
5883
5900
|
var onAfterConnected = createLifecycleDecorator(ON_AFTER_CONNECTED_METADATA_KEY);
|
|
5884
5901
|
var onConnected = onAfterConnected;
|
|
@@ -5959,6 +5976,20 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
5959
5976
|
ReflectUtils.defineMetadata(ATTRIBUTE_METADATA_KEY, metaList, constructor);
|
|
5960
5977
|
}
|
|
5961
5978
|
metaList.push({ propertyKey, selector, options, privateKey });
|
|
5979
|
+
const applySetAttribute = (inst, targets, attrName, nv) => {
|
|
5980
|
+
targets.forEach((it) => {
|
|
5981
|
+
console.log("----->", it);
|
|
5982
|
+
if (it && typeof it.setAttribute === "function") {
|
|
5983
|
+
if (nv === null) {
|
|
5984
|
+
it.removeAttribute(attrName);
|
|
5985
|
+
} else {
|
|
5986
|
+
it.setAttribute(attrName, String(nv));
|
|
5987
|
+
}
|
|
5988
|
+
} else {
|
|
5989
|
+
inst[privateKey] = nv;
|
|
5990
|
+
}
|
|
5991
|
+
});
|
|
5992
|
+
};
|
|
5962
5993
|
Object.defineProperty(target, propertyKey, {
|
|
5963
5994
|
get() {
|
|
5964
5995
|
const attrName = options.name || String(propertyKey);
|
|
@@ -5982,22 +6013,25 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
5982
6013
|
},
|
|
5983
6014
|
set(nv) {
|
|
5984
6015
|
const targetType = options.type || designType;
|
|
6016
|
+
console.log("---set", propertyKey, targetType, nv, this, this.__swc_syncing_init);
|
|
5985
6017
|
const attrName = options.name || String(propertyKey);
|
|
5986
6018
|
const conf = getElementConfig(this);
|
|
5987
6019
|
const currentWin = this._resolveWindow?.(conf) || (typeof window !== "undefined" ? window : void 0);
|
|
5988
|
-
|
|
5989
|
-
|
|
5990
|
-
|
|
5991
|
-
|
|
5992
|
-
if (nv === null) {
|
|
5993
|
-
it.removeAttribute(attrName);
|
|
5994
|
-
} else {
|
|
5995
|
-
it.setAttribute(attrName, String(nv));
|
|
5996
|
-
}
|
|
6020
|
+
if (this.__swc_syncing_init) {
|
|
6021
|
+
if (options.connectedInitialize === true) {
|
|
6022
|
+
const targets2 = resolveTargetEls(this, selector, options, currentWin);
|
|
6023
|
+
applySetAttribute(this, targets2, attrName, nv);
|
|
5997
6024
|
} else {
|
|
5998
6025
|
this[privateKey] = nv;
|
|
5999
6026
|
}
|
|
6000
|
-
|
|
6027
|
+
return;
|
|
6028
|
+
}
|
|
6029
|
+
if (!this.__swc_connected) {
|
|
6030
|
+
this[privateKey] = nv;
|
|
6031
|
+
return;
|
|
6032
|
+
}
|
|
6033
|
+
const targets = resolveTargetEls(this, selector, options, currentWin);
|
|
6034
|
+
applySetAttribute(this, targets, attrName, nv);
|
|
6001
6035
|
},
|
|
6002
6036
|
enumerable: true,
|
|
6003
6037
|
configurable: true
|
|
@@ -6007,10 +6041,13 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
6007
6041
|
var findAllAttributeMetadata = (target) => {
|
|
6008
6042
|
return ReflectUtils.findAllMetadata(ATTRIBUTE_METADATA_KEY, target).flat();
|
|
6009
6043
|
};
|
|
6044
|
+
function attributeHost(attrName, options = {}) {
|
|
6045
|
+
return attribute(":host", { ...options, name: attrName });
|
|
6046
|
+
}
|
|
6010
6047
|
|
|
6011
|
-
// src/decorators/
|
|
6048
|
+
// src/decorators/changedAttributeHost.ts
|
|
6012
6049
|
var ON_ATTRIBUTE_CHANGED_METADATA_KEY = Symbol("simple-web-component:on-attribute-changed");
|
|
6013
|
-
function
|
|
6050
|
+
function changedAttributeHost(attributeName) {
|
|
6014
6051
|
return (target, propertyKey) => {
|
|
6015
6052
|
const constructor = target.constructor;
|
|
6016
6053
|
let meta = ReflectUtils.getOwnMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, constructor);
|
|
@@ -6114,62 +6151,12 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
6114
6151
|
});
|
|
6115
6152
|
return result;
|
|
6116
6153
|
};
|
|
6117
|
-
|
|
6118
|
-
|
|
6119
|
-
var REPLACE_CHILDREN_METADATA_KEY = Symbol("simple-web-component:replace-children");
|
|
6120
|
-
function replaceChildren(selector) {
|
|
6121
|
-
return (target, propertyKey, descriptor) => {
|
|
6122
|
-
const constructor = target.constructor;
|
|
6123
|
-
let meta = ReflectUtils.getOwnMetadata(REPLACE_CHILDREN_METADATA_KEY, constructor);
|
|
6124
|
-
if (!meta) {
|
|
6125
|
-
meta = /* @__PURE__ */ new Map();
|
|
6126
|
-
ReflectUtils.defineMetadata(REPLACE_CHILDREN_METADATA_KEY, meta, constructor);
|
|
6127
|
-
}
|
|
6128
|
-
meta.set(propertyKey, selector);
|
|
6129
|
-
const original = descriptor.value;
|
|
6130
|
-
descriptor.value = async function(...args) {
|
|
6131
|
-
ensureInit2(this);
|
|
6132
|
-
const res = await original.apply(this, args);
|
|
6133
|
-
if (res !== void 0) {
|
|
6134
|
-
const conf = getElementConfig(this);
|
|
6135
|
-
const currentWin = this._resolveWindow?.(conf) || (typeof window !== "undefined" ? window : void 0);
|
|
6136
|
-
const currentDoc = currentWin.document;
|
|
6137
|
-
let targetEl = null;
|
|
6138
|
-
if (selector === ":host" || !selector) {
|
|
6139
|
-
targetEl = this;
|
|
6140
|
-
} else {
|
|
6141
|
-
targetEl = (this.shadowRoot || this).querySelector(selector);
|
|
6142
|
-
}
|
|
6143
|
-
if (targetEl) {
|
|
6144
|
-
if (typeof res === "string") {
|
|
6145
|
-
targetEl.textContent = res;
|
|
6146
|
-
} else {
|
|
6147
|
-
const nodes = Array.isArray(res) ? res.map((n) => typeof n === "string" ? currentDoc.createTextNode(n) : n) : [res];
|
|
6148
|
-
targetEl.replaceChildren(...nodes);
|
|
6149
|
-
}
|
|
6150
|
-
}
|
|
6151
|
-
}
|
|
6152
|
-
return res;
|
|
6153
|
-
};
|
|
6154
|
-
};
|
|
6154
|
+
function setAttributeHost(name, options) {
|
|
6155
|
+
return setAttribute(":host", name, options);
|
|
6155
6156
|
}
|
|
6156
|
-
var getReplaceChildrenMetadata = (target) => {
|
|
6157
|
-
const constructor = target instanceof Function ? target : target.constructor;
|
|
6158
|
-
return ReflectUtils.getMetadata(REPLACE_CHILDREN_METADATA_KEY, constructor);
|
|
6159
|
-
};
|
|
6160
|
-
var findAllReplaceChildrenMetadata = (target) => {
|
|
6161
|
-
const result = /* @__PURE__ */ new Map();
|
|
6162
|
-
const maps = ReflectUtils.findAllMetadata(REPLACE_CHILDREN_METADATA_KEY, target);
|
|
6163
|
-
maps.forEach((map) => {
|
|
6164
|
-
if (map instanceof Map) {
|
|
6165
|
-
map.forEach((v, k) => result.set(k, v));
|
|
6166
|
-
}
|
|
6167
|
-
});
|
|
6168
|
-
return result;
|
|
6169
|
-
};
|
|
6170
6157
|
|
|
6171
|
-
// src/decorators/
|
|
6172
|
-
var
|
|
6158
|
+
// src/decorators/applyNode.ts
|
|
6159
|
+
var APPLY_NODE_METADATA_KEY = Symbol("simple-web-component:apply-node");
|
|
6173
6160
|
var normalizeNodes = (res, doc) => {
|
|
6174
6161
|
const items = Array.isArray(res) ? res : [res];
|
|
6175
6162
|
return items.map((it) => {
|
|
@@ -6178,13 +6165,13 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
6178
6165
|
return doc.createTextNode(it !== void 0 && it !== null ? String(it) : "");
|
|
6179
6166
|
});
|
|
6180
6167
|
};
|
|
6181
|
-
function
|
|
6168
|
+
function applyNode(selector, options = { position: "beforeEnd" }) {
|
|
6182
6169
|
return (target, propertyKey, descriptor) => {
|
|
6183
6170
|
const constructor = target.constructor;
|
|
6184
|
-
let metaList = ReflectUtils.getOwnMetadata(
|
|
6171
|
+
let metaList = ReflectUtils.getOwnMetadata(APPLY_NODE_METADATA_KEY, constructor);
|
|
6185
6172
|
if (!metaList) {
|
|
6186
6173
|
metaList = /* @__PURE__ */ new Map();
|
|
6187
|
-
ReflectUtils.defineMetadata(
|
|
6174
|
+
ReflectUtils.defineMetadata(APPLY_NODE_METADATA_KEY, metaList, constructor);
|
|
6188
6175
|
}
|
|
6189
6176
|
metaList.set(propertyKey, { propertyKey, selector, options });
|
|
6190
6177
|
const original = descriptor.value;
|
|
@@ -6204,10 +6191,14 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
6204
6191
|
if (targetEl) {
|
|
6205
6192
|
const nodes = normalizeNodes(res, currentDoc);
|
|
6206
6193
|
const pos = options.position || "beforeEnd";
|
|
6207
|
-
if (
|
|
6208
|
-
targetEl.
|
|
6209
|
-
} else if (
|
|
6210
|
-
targetEl.
|
|
6194
|
+
if (pos === "replace") {
|
|
6195
|
+
targetEl.replaceWith(...nodes);
|
|
6196
|
+
} else if (pos === "replaceChildren") {
|
|
6197
|
+
targetEl.replaceChildren(...nodes);
|
|
6198
|
+
} else if (pos === "innerHtml") {
|
|
6199
|
+
targetEl.innerHTML = res !== void 0 && res !== null ? String(res) : "";
|
|
6200
|
+
} else if (pos === "innerText") {
|
|
6201
|
+
targetEl.innerText = res !== void 0 && res !== null ? String(res) : "";
|
|
6211
6202
|
} else {
|
|
6212
6203
|
if (pos === "beforeEnd")
|
|
6213
6204
|
targetEl.append(...nodes);
|
|
@@ -6224,9 +6215,9 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
6224
6215
|
};
|
|
6225
6216
|
};
|
|
6226
6217
|
}
|
|
6227
|
-
var
|
|
6218
|
+
var findAllApplyNodeMetadata = (target) => {
|
|
6228
6219
|
const result = /* @__PURE__ */ new Map();
|
|
6229
|
-
const maps = ReflectUtils.findAllMetadata(
|
|
6220
|
+
const maps = ReflectUtils.findAllMetadata(APPLY_NODE_METADATA_KEY, target);
|
|
6230
6221
|
maps.forEach((map) => {
|
|
6231
6222
|
if (map instanceof Map) {
|
|
6232
6223
|
map.forEach((v, k) => result.set(k, v));
|
|
@@ -6234,6 +6225,9 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
6234
6225
|
});
|
|
6235
6226
|
return result;
|
|
6236
6227
|
};
|
|
6228
|
+
function applyNodeHost(options = { position: "beforeEnd" }) {
|
|
6229
|
+
return applyNode(":host", options);
|
|
6230
|
+
}
|
|
6237
6231
|
|
|
6238
6232
|
// src/decorators/query.ts
|
|
6239
6233
|
var QUERY_METADATA_KEY = Symbol("simple-web-component:query");
|
|
@@ -6334,6 +6328,9 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
6334
6328
|
const constructor = target instanceof Function ? target : target.constructor;
|
|
6335
6329
|
return ReflectUtils.getMetadata(QUERY_METADATA_KEY, constructor);
|
|
6336
6330
|
};
|
|
6331
|
+
function queryHost(options) {
|
|
6332
|
+
return query(":host", options);
|
|
6333
|
+
}
|
|
6337
6334
|
|
|
6338
6335
|
// src/decorators/queryAll.ts
|
|
6339
6336
|
var QUERY_ALL_METADATA_KEY = Symbol("simple-web-component:query-all");
|
|
@@ -6431,6 +6428,9 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
6431
6428
|
const constructor = target instanceof Function ? target : target.constructor;
|
|
6432
6429
|
return ReflectUtils.getMetadata(QUERY_ALL_METADATA_KEY, constructor);
|
|
6433
6430
|
};
|
|
6431
|
+
function queryAllHost(options) {
|
|
6432
|
+
return queryAll(":host", options);
|
|
6433
|
+
}
|
|
6434
6434
|
|
|
6435
6435
|
// src/decorators/classList.ts
|
|
6436
6436
|
var CLASS_LIST_METADATA_KEY = Symbol("simple-web-component:class-list");
|
|
@@ -6495,6 +6495,11 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
6495
6495
|
var addClassList = createClassListDecorator("add");
|
|
6496
6496
|
var removeClassList = createClassListDecorator("remove");
|
|
6497
6497
|
var toggleClassList = createClassListDecorator("toggle");
|
|
6498
|
+
var setClassListHost = createClassListDecorator("set").bind(null, ":host");
|
|
6499
|
+
var updateClassListHost = createClassListDecorator("update").bind(null, ":host");
|
|
6500
|
+
var addClassListHost = createClassListDecorator("add").bind(null, ":host");
|
|
6501
|
+
var removeClassListHost = createClassListDecorator("remove").bind(null, ":host");
|
|
6502
|
+
var toggleClassListHost = createClassListDecorator("toggle").bind(null, ":host");
|
|
6498
6503
|
var findAllClassListMetadata = (target) => {
|
|
6499
6504
|
const result = /* @__PURE__ */ new Map();
|
|
6500
6505
|
const maps = ReflectUtils.findAllMetadata(CLASS_LIST_METADATA_KEY, target);
|
|
@@ -6684,9 +6689,6 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
6684
6689
|
return (targetObj, propertyKey, descriptor) => {
|
|
6685
6690
|
const constructor = targetObj.constructor;
|
|
6686
6691
|
const fullOptions = { ...options, type };
|
|
6687
|
-
if (!fullOptions.attributeName) {
|
|
6688
|
-
fullOptions.attributeName = `swc-on-${type}`;
|
|
6689
|
-
}
|
|
6690
6692
|
if (fullOptions.bubbles === void 0) fullOptions.bubbles = true;
|
|
6691
6693
|
if (fullOptions.composed === void 0) fullOptions.composed = true;
|
|
6692
6694
|
let list = ReflectUtils.getMetadata(EMIT_CUSTOM_EVENT_METADATA_KEY, constructor);
|
|
@@ -6751,6 +6753,9 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
6751
6753
|
const constructor = target instanceof Function ? target : target.constructor;
|
|
6752
6754
|
return ReflectUtils.getMetadata(EMIT_CUSTOM_EVENT_METADATA_KEY, constructor);
|
|
6753
6755
|
};
|
|
6756
|
+
function emitCustomEventHost(type, options) {
|
|
6757
|
+
return emitCustomEvent(":host", type, options);
|
|
6758
|
+
}
|
|
6754
6759
|
|
|
6755
6760
|
// src/config/config.ts
|
|
6756
6761
|
var HTML_TAG_ENTRIES = [
|
|
@@ -6871,6 +6876,10 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
6871
6876
|
inst.__swc_initialized = true;
|
|
6872
6877
|
const hostSet = SwcUtils.getHostSet(inst);
|
|
6873
6878
|
inst._executeSwcScript?.("swc-on-constructor", hostSet);
|
|
6879
|
+
const cMethods = findAllLifecycleMetadata(inst, ON_CONSTRUCTOR_METADATA_KEY);
|
|
6880
|
+
if (cMethods) {
|
|
6881
|
+
for (const m of cMethods) inst._invokeLifecycleMethod(m, hostSet);
|
|
6882
|
+
}
|
|
6874
6883
|
}
|
|
6875
6884
|
};
|
|
6876
6885
|
var globalDelegatedRoots = /* @__PURE__ */ new WeakSet();
|
|
@@ -6969,7 +6978,9 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
6969
6978
|
const oldHandler = handlers.get(attrName);
|
|
6970
6979
|
if (oldHandler) el.removeEventListener(eventName, oldHandler);
|
|
6971
6980
|
const handler = async (event) => {
|
|
6972
|
-
|
|
6981
|
+
console.log("execute handler", event);
|
|
6982
|
+
const parent = SwcUtils.findNearestSwcHost(el);
|
|
6983
|
+
const hostSet = SwcUtils.getHostSet(parent || el);
|
|
6973
6984
|
const conf = getElementConfig(this);
|
|
6974
6985
|
const currentWin = this._resolveWindow(conf);
|
|
6975
6986
|
const helpers = SwcUtils.getHelperSet(currentWin);
|
|
@@ -6988,13 +6999,18 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
6988
6999
|
};
|
|
6989
7000
|
proto.__swc_executeAttributeEvent = async function(el, attrName, script, event) {
|
|
6990
7001
|
ensureInit2(this);
|
|
6991
|
-
|
|
7002
|
+
console.log("execute handler2", event);
|
|
7003
|
+
const parent = SwcUtils.findNearestSwcHost(el);
|
|
7004
|
+
const hostSet = SwcUtils.getHostSet(parent || el);
|
|
6992
7005
|
const conf = getElementConfig(this);
|
|
6993
7006
|
const currentWin = this._resolveWindow(conf);
|
|
6994
7007
|
const currentHelpers = SwcUtils.getHelperSet(currentWin);
|
|
7008
|
+
const detail = event.detail;
|
|
6995
7009
|
const args = {
|
|
6996
7010
|
event,
|
|
6997
|
-
$
|
|
7011
|
+
$event: event,
|
|
7012
|
+
$data: detail,
|
|
7013
|
+
$detail: detail,
|
|
6998
7014
|
...hostSet,
|
|
6999
7015
|
...currentHelpers,
|
|
7000
7016
|
$el: el,
|
|
@@ -7021,12 +7037,14 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
7021
7037
|
metadata.extends = extendsTagName;
|
|
7022
7038
|
}
|
|
7023
7039
|
const emitCustomEventList = getEmitCustomEventMetadataList(constructor) || [];
|
|
7040
|
+
const emitHostCustomEventList = emitCustomEventList.filter((meta) => meta.selector === ":host" || meta.selector === "");
|
|
7024
7041
|
const addEventListenerList = getAddEventListenerMetadata(constructor) || [];
|
|
7042
|
+
const addHostEventListenerList = addEventListenerList.filter((meta) => meta.selector === ":host" || meta.selector === "");
|
|
7025
7043
|
const attrChangeMap = findAllAttributeChangedMetadata(constructor);
|
|
7026
7044
|
const attributeList = findAllAttributeMetadata(constructor);
|
|
7027
7045
|
const swcLifecycleAttributes = ["swc-on-constructor", "swc-on-connected", "swc-on-disconnected", "swc-on-before-connected", "swc-on-after-connected", "swc-on-before-disconnected", "swc-on-after-disconnected", "swc-on-before-adopted", "swc-on-after-adopted", "swc-on-attribute-changed"];
|
|
7028
7046
|
const swcOnEvents = DOM_EVENT_NAMES.map((e) => `swc-on-${e}`);
|
|
7029
|
-
const mergedObservedAttributes = [.../* @__PURE__ */ new Set([...metadata.observedAttributes ?? [], ...attrChangeMap.keys(), ...Array.from(findAllSetAttributeMetadata(constructor).values()).map((it) => it.name), ...attributeList.map((it) => it.options.name || String(it.propertyKey)), ...
|
|
7047
|
+
const mergedObservedAttributes = [.../* @__PURE__ */ new Set([...metadata.observedAttributes ?? [], ...attrChangeMap.keys(), ...Array.from(findAllSetAttributeMetadata(constructor).values()).map((it) => it.name), ...attributeList.map((it) => it.options.name || String(it.propertyKey)), ...emitHostCustomEventList.map((it) => it.options.attributeName).filter(Boolean), ...swcLifecycleAttributes, ...swcOnEvents])];
|
|
7030
7048
|
const connectedInnerHtmlList = getOnConnectedInnerHtmlMetadata(constructor) || [];
|
|
7031
7049
|
const proto = constructor.prototype;
|
|
7032
7050
|
setupPrototype(proto);
|
|
@@ -7046,25 +7064,15 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
7046
7064
|
}
|
|
7047
7065
|
attributeList.forEach((meta) => {
|
|
7048
7066
|
const attrName = meta.options.name || String(meta.propertyKey);
|
|
7049
|
-
if (meta.options.connectedInitialize) {
|
|
7050
|
-
|
|
7051
|
-
|
|
7052
|
-
|
|
7053
|
-
|
|
7067
|
+
if (meta.options.connectedInitialize === true) {
|
|
7068
|
+
this.__swc_syncing_init = true;
|
|
7069
|
+
try {
|
|
7070
|
+
const memoryVal = this[meta.privateKey];
|
|
7071
|
+
if (memoryVal !== void 0) {
|
|
7054
7072
|
this[meta.propertyKey] = memoryVal;
|
|
7055
|
-
} finally {
|
|
7056
|
-
this.__swc_syncing_init = false;
|
|
7057
|
-
}
|
|
7058
|
-
}
|
|
7059
|
-
} else if (meta.selector === ":host" || !meta.selector) {
|
|
7060
|
-
const domVal = this.getAttribute(attrName);
|
|
7061
|
-
if (domVal !== null) {
|
|
7062
|
-
this.__swc_syncing_init = true;
|
|
7063
|
-
try {
|
|
7064
|
-
this[meta.propertyKey] = domVal;
|
|
7065
|
-
} finally {
|
|
7066
|
-
this.__swc_syncing_init = false;
|
|
7067
7073
|
}
|
|
7074
|
+
} finally {
|
|
7075
|
+
this.__swc_syncing_init = false;
|
|
7068
7076
|
}
|
|
7069
7077
|
}
|
|
7070
7078
|
});
|
|
@@ -7087,7 +7095,62 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
7087
7095
|
});
|
|
7088
7096
|
globalDelegatedRoots.add(root);
|
|
7089
7097
|
}
|
|
7098
|
+
const delegateListeners = [];
|
|
7099
|
+
const nonDelegateListeners = [];
|
|
7090
7100
|
addEventListenerList.forEach((meta) => {
|
|
7101
|
+
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 !== "") {
|
|
7102
|
+
delegateListeners.push(meta);
|
|
7103
|
+
} else {
|
|
7104
|
+
nonDelegateListeners.push(meta);
|
|
7105
|
+
}
|
|
7106
|
+
});
|
|
7107
|
+
const delegatesByTypeAndRoot = /* @__PURE__ */ new Map();
|
|
7108
|
+
delegateListeners.forEach((meta) => {
|
|
7109
|
+
const r = meta.options.root || "auto";
|
|
7110
|
+
const rootKey = `${meta.type}:${r}`;
|
|
7111
|
+
if (!delegatesByTypeAndRoot.has(rootKey)) {
|
|
7112
|
+
delegatesByTypeAndRoot.set(rootKey, []);
|
|
7113
|
+
}
|
|
7114
|
+
delegatesByTypeAndRoot.get(rootKey).push(meta);
|
|
7115
|
+
});
|
|
7116
|
+
delegatesByTypeAndRoot.forEach((metaList, typeRootKey) => {
|
|
7117
|
+
const [type, rStr] = typeRootKey.split(":");
|
|
7118
|
+
const r = rStr === "auto" ? "auto" : rStr;
|
|
7119
|
+
const opts = { capture: metaList[0].options.capture, once: metaList[0].options.once, passive: metaList[0].options.passive };
|
|
7120
|
+
const bindRoots = [];
|
|
7121
|
+
if (r === "auto") bindRoots.push(this.shadowRoot || this);
|
|
7122
|
+
else if (r === "light") bindRoots.push(this);
|
|
7123
|
+
else if (r === "shadow" && this.shadowRoot) bindRoots.push(this.shadowRoot);
|
|
7124
|
+
else if (r === "all") {
|
|
7125
|
+
bindRoots.push(this);
|
|
7126
|
+
if (this.shadowRoot) bindRoots.push(this.shadowRoot);
|
|
7127
|
+
}
|
|
7128
|
+
bindRoots.forEach((br) => {
|
|
7129
|
+
const sortedMetaList = [...metaList].sort((a, b) => {
|
|
7130
|
+
const aStop = a.options.stopPropagation ? 1 : 0;
|
|
7131
|
+
const bStop = b.options.stopPropagation ? 1 : 0;
|
|
7132
|
+
return bStop - aStop;
|
|
7133
|
+
});
|
|
7134
|
+
const unifiedHandler = async (event) => {
|
|
7135
|
+
for (const meta of sortedMetaList) {
|
|
7136
|
+
const { selector, options } = meta;
|
|
7137
|
+
const matchedEl = event.target.closest(selector);
|
|
7138
|
+
if (matchedEl && br.contains(matchedEl)) {
|
|
7139
|
+
if (options.stopPropagation) event.stopPropagation();
|
|
7140
|
+
if (options.stopImmediatePropagation) event.stopImmediatePropagation();
|
|
7141
|
+
if (options.preventDefault) event.preventDefault();
|
|
7142
|
+
const currentHostSet = SwcUtils.getHostSet(this);
|
|
7143
|
+
const args = { event, ...currentHostSet, $el: matchedEl, $root: br };
|
|
7144
|
+
await this[meta.propertyKey](event, currentHostSet, matchedEl, args);
|
|
7145
|
+
if (event.cancelBubble) break;
|
|
7146
|
+
}
|
|
7147
|
+
}
|
|
7148
|
+
};
|
|
7149
|
+
br.addEventListener(type, unifiedHandler, opts);
|
|
7150
|
+
this._boundListeners.push({ target: br, type, handler: unifiedHandler, options: opts });
|
|
7151
|
+
});
|
|
7152
|
+
});
|
|
7153
|
+
nonDelegateListeners.forEach((meta) => {
|
|
7091
7154
|
const { selector, type, options } = meta;
|
|
7092
7155
|
const opts = { capture: options.capture, once: options.once, passive: options.passive };
|
|
7093
7156
|
const bindTargets = [];
|
|
@@ -7112,33 +7175,7 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
7112
7175
|
else if (selector === ":hosts") hostSet.$hosts.forEach(applyRootOption);
|
|
7113
7176
|
else if (selector === ":appHosts") hostSet.$appHosts.forEach(applyRootOption);
|
|
7114
7177
|
else if (selector === ":host" || !selector) applyRootOption(this);
|
|
7115
|
-
else
|
|
7116
|
-
const bindRoots = [];
|
|
7117
|
-
if (r === "auto") bindRoots.push(this.shadowRoot || this);
|
|
7118
|
-
else if (r === "light") bindRoots.push(this);
|
|
7119
|
-
else if (r === "shadow" && this.shadowRoot) bindRoots.push(this.shadowRoot);
|
|
7120
|
-
else if (r === "all") {
|
|
7121
|
-
bindRoots.push(this);
|
|
7122
|
-
if (this.shadowRoot) bindRoots.push(this.shadowRoot);
|
|
7123
|
-
}
|
|
7124
|
-
bindRoots.forEach((br) => {
|
|
7125
|
-
const handler = async (event) => {
|
|
7126
|
-
const matchedEl = event.target.closest(selector);
|
|
7127
|
-
if (matchedEl && br.contains(matchedEl)) {
|
|
7128
|
-
if (options.stopPropagation) event.stopPropagation();
|
|
7129
|
-
if (options.stopImmediatePropagation) event.stopImmediatePropagation();
|
|
7130
|
-
if (options.preventDefault) event.preventDefault();
|
|
7131
|
-
const currentHostSet = SwcUtils.getHostSet(this);
|
|
7132
|
-
const args = { event, ...currentHostSet, $el: matchedEl, $root: br };
|
|
7133
|
-
await this._invokeLifecycleMethod(meta.propertyKey, currentHostSet, [event, currentHostSet, matchedEl, args]);
|
|
7134
|
-
}
|
|
7135
|
-
};
|
|
7136
|
-
br.addEventListener(type, handler, opts);
|
|
7137
|
-
if (options.removeOnDisconnected === true || br !== this && br !== this.shadowRoot) {
|
|
7138
|
-
this._boundListeners.push({ target: br, type, handler, options: opts });
|
|
7139
|
-
}
|
|
7140
|
-
});
|
|
7141
|
-
} else {
|
|
7178
|
+
else {
|
|
7142
7179
|
const searchRoots = [];
|
|
7143
7180
|
if (r === "auto") searchRoots.push(this.shadowRoot || this);
|
|
7144
7181
|
else if (r === "light") searchRoots.push(this);
|
|
@@ -7158,7 +7195,7 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
7158
7195
|
if (options.preventDefault) event.preventDefault();
|
|
7159
7196
|
const currentHostSet = SwcUtils.getHostSet(this);
|
|
7160
7197
|
const args = { event, ...currentHostSet, $el: t, $root: t };
|
|
7161
|
-
await this
|
|
7198
|
+
await this[meta.propertyKey](event, currentHostSet, args);
|
|
7162
7199
|
};
|
|
7163
7200
|
t.addEventListener(type, handler, opts);
|
|
7164
7201
|
if (options.removeOnDisconnected === true || t === currentWin || t === currentWin.document) {
|
|
@@ -7166,6 +7203,22 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
7166
7203
|
}
|
|
7167
7204
|
});
|
|
7168
7205
|
});
|
|
7206
|
+
addHostEventListenerList.forEach((meta) => {
|
|
7207
|
+
const { type, options } = meta;
|
|
7208
|
+
const opts = { capture: options.capture, once: options.once, passive: options.passive };
|
|
7209
|
+
const handler = async (event) => {
|
|
7210
|
+
if (options.stopPropagation) event.stopPropagation();
|
|
7211
|
+
if (options.stopImmediatePropagation) event.stopImmediatePropagation();
|
|
7212
|
+
if (options.preventDefault) event.preventDefault();
|
|
7213
|
+
const currentHostSet = SwcUtils.getHostSet(this);
|
|
7214
|
+
const args = { event, ...currentHostSet, $el: this, $root: this.getRootNode() };
|
|
7215
|
+
await this[meta.propertyKey](event, currentHostSet, args);
|
|
7216
|
+
};
|
|
7217
|
+
this.addEventListener(type, handler, opts);
|
|
7218
|
+
if (options.removeOnDisconnected === true) {
|
|
7219
|
+
this._boundListeners.push({ target: this, type, handler, options: opts });
|
|
7220
|
+
}
|
|
7221
|
+
});
|
|
7169
7222
|
if (originalConnected) originalConnected.apply(this);
|
|
7170
7223
|
const aMethods = findAllLifecycleMetadata(this, ON_AFTER_CONNECTED_METADATA_KEY);
|
|
7171
7224
|
if (aMethods) {
|
|
@@ -7215,17 +7268,20 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
7215
7268
|
const originalAttributeChanged = proto.attributeChangedCallback;
|
|
7216
7269
|
proto.attributeChangedCallback = function(name2, old, newVal) {
|
|
7217
7270
|
if (originalAttributeChanged) originalAttributeChanged.apply(this, [name2, old, newVal]);
|
|
7271
|
+
const hSet = SwcUtils.getHostSet(this);
|
|
7218
7272
|
if (name2.startsWith("swc-on-") && !swcLifecycleAttributes.includes(name2)) {
|
|
7219
7273
|
if (newVal !== null) {
|
|
7220
|
-
const
|
|
7221
|
-
const eventName = customEventMeta ? customEventMeta.type : name2.substring(7);
|
|
7274
|
+
const eventName = name2.substring(7);
|
|
7222
7275
|
this._bindAttributeEvent(this, name2, newVal, eventName);
|
|
7223
7276
|
}
|
|
7224
7277
|
}
|
|
7278
|
+
const hostCustomEventMeta = emitHostCustomEventList.find((it) => it.options.attributeName === name2);
|
|
7279
|
+
if (hostCustomEventMeta && newVal !== null) {
|
|
7280
|
+
this._bindAttributeEvent(this, name2, newVal, hostCustomEventMeta.type);
|
|
7281
|
+
}
|
|
7225
7282
|
const mKeys = attrChangeMap.get(name2);
|
|
7226
7283
|
if (mKeys && Array.isArray(mKeys)) {
|
|
7227
|
-
const
|
|
7228
|
-
for (const key of mKeys) this._invokeLifecycleMethod(key, hSet, [newVal, old, name2]);
|
|
7284
|
+
for (const key of mKeys) this[key](newVal, old, name2, hSet);
|
|
7229
7285
|
}
|
|
7230
7286
|
};
|
|
7231
7287
|
Object.defineProperty(constructor, "observedAttributes", {
|