saloe 0.0.56 → 0.0.57
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/dist/listener.cjs.js +13 -1
- package/dist/listener.es.js +13 -1
- package/package.json +1 -1
- package/src/listener.js +17 -3
package/dist/listener.cjs.js
CHANGED
|
@@ -149,16 +149,28 @@ const listener = ({
|
|
|
149
149
|
if (closestButton) return closestButton;
|
|
150
150
|
return srcElement;
|
|
151
151
|
};
|
|
152
|
+
const cloneSrcElement = ({ srcElement }) => {
|
|
153
|
+
const newSrcElement = document.createElement(srcElement == null ? void 0 : srcElement.tagName);
|
|
154
|
+
srcElement == null ? void 0 : srcElement.attributes.forEach((attr) => {
|
|
155
|
+
if (attr.startsWith("on-")) return;
|
|
156
|
+
newSrcElement.setAttribute(attr.name, attr.value);
|
|
157
|
+
});
|
|
158
|
+
return newSrcElement;
|
|
159
|
+
};
|
|
152
160
|
const fireAnchorClickListener = () => {
|
|
153
161
|
const anchors = document.querySelectorAll("a[on-click]");
|
|
154
162
|
anchors == null ? void 0 : anchors.forEach((anchor) => {
|
|
155
163
|
anchor.addEventListener("click", async (e) => {
|
|
164
|
+
e.preventDefault();
|
|
156
165
|
const srcElement = anchor;
|
|
157
166
|
const event = "click";
|
|
158
167
|
const listeners = await fetchListeners({ srcElement, event, e });
|
|
159
168
|
executeListeners({ e, srcElement, listeners });
|
|
160
169
|
if (srcElement == null ? void 0 : srcElement.removeAttribute) srcElement.removeAttribute(`on-${event}`);
|
|
161
|
-
|
|
170
|
+
setTimeout(() => {
|
|
171
|
+
const newAnchor = cloneSrcElement({ srcElement });
|
|
172
|
+
newAnchor.click();
|
|
173
|
+
}, 1e3);
|
|
162
174
|
});
|
|
163
175
|
});
|
|
164
176
|
};
|
package/dist/listener.es.js
CHANGED
|
@@ -147,16 +147,28 @@ const listener = ({
|
|
|
147
147
|
if (closestButton) return closestButton;
|
|
148
148
|
return srcElement;
|
|
149
149
|
};
|
|
150
|
+
const cloneSrcElement = ({ srcElement }) => {
|
|
151
|
+
const newSrcElement = document.createElement(srcElement == null ? void 0 : srcElement.tagName);
|
|
152
|
+
srcElement == null ? void 0 : srcElement.attributes.forEach((attr) => {
|
|
153
|
+
if (attr.startsWith("on-")) return;
|
|
154
|
+
newSrcElement.setAttribute(attr.name, attr.value);
|
|
155
|
+
});
|
|
156
|
+
return newSrcElement;
|
|
157
|
+
};
|
|
150
158
|
const fireAnchorClickListener = () => {
|
|
151
159
|
const anchors = document.querySelectorAll("a[on-click]");
|
|
152
160
|
anchors == null ? void 0 : anchors.forEach((anchor) => {
|
|
153
161
|
anchor.addEventListener("click", async (e) => {
|
|
162
|
+
e.preventDefault();
|
|
154
163
|
const srcElement = anchor;
|
|
155
164
|
const event = "click";
|
|
156
165
|
const listeners = await fetchListeners({ srcElement, event, e });
|
|
157
166
|
executeListeners({ e, srcElement, listeners });
|
|
158
167
|
if (srcElement == null ? void 0 : srcElement.removeAttribute) srcElement.removeAttribute(`on-${event}`);
|
|
159
|
-
|
|
168
|
+
setTimeout(() => {
|
|
169
|
+
const newAnchor = cloneSrcElement({ srcElement });
|
|
170
|
+
newAnchor.click();
|
|
171
|
+
}, 1e3);
|
|
160
172
|
});
|
|
161
173
|
});
|
|
162
174
|
};
|
package/package.json
CHANGED
package/src/listener.js
CHANGED
|
@@ -214,11 +214,22 @@ const listener = ({
|
|
|
214
214
|
return srcElement
|
|
215
215
|
}
|
|
216
216
|
|
|
217
|
+
const cloneSrcElement = ({ srcElement }) => {
|
|
218
|
+
const newSrcElement = document.createElement(srcElement?.tagName)
|
|
219
|
+
|
|
220
|
+
srcElement?.attributes.forEach((attr) => {
|
|
221
|
+
if (attr.startsWith('on-')) return
|
|
222
|
+
newSrcElement.setAttribute(attr.name, attr.value)
|
|
223
|
+
})
|
|
224
|
+
|
|
225
|
+
return newSrcElement
|
|
226
|
+
}
|
|
227
|
+
|
|
217
228
|
const fireAnchorClickListener = () => {
|
|
218
229
|
const anchors = document.querySelectorAll('a[on-click]')
|
|
219
230
|
anchors?.forEach((anchor) => {
|
|
220
231
|
anchor.addEventListener('click', async (e) => {
|
|
221
|
-
|
|
232
|
+
e.preventDefault()
|
|
222
233
|
|
|
223
234
|
const srcElement = anchor
|
|
224
235
|
const event = 'click'
|
|
@@ -226,8 +237,11 @@ const listener = ({
|
|
|
226
237
|
|
|
227
238
|
executeListeners({ e, srcElement, listeners })
|
|
228
239
|
if (srcElement?.removeAttribute) srcElement.removeAttribute(`on-${event}`)
|
|
229
|
-
|
|
230
|
-
|
|
240
|
+
|
|
241
|
+
setTimeout(() => {
|
|
242
|
+
const newAnchor = cloneSrcElement({ srcElement })
|
|
243
|
+
newAnchor.click()
|
|
244
|
+
}, 1_000)
|
|
231
245
|
|
|
232
246
|
// location.href = anchor.href
|
|
233
247
|
})
|