File tree Expand file tree Collapse file tree 2 files changed +25
-11
lines changed
Expand file tree Collapse file tree 2 files changed +25
-11
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " tauri " : patch
3+ ---
4+
5+ Fixes access to the ` WebviewWindow.getByLabel ` function in a ` tauri://window-created ` event listener.
Original file line number Diff line number Diff line change @@ -327,17 +327,26 @@ pub fn listen_js(
327327 handler : String ,
328328) -> String {
329329 format ! (
330- "if (window['{listeners}'] === void 0) {{
331- Object.defineProperty(window, '{listeners}', {{ value: Object.create(null) }});
332- }}
333- if (window['{listeners}'][{event}] === void 0) {{
334- Object.defineProperty(window['{listeners}'], {event}, {{ value: [] }});
335- }}
336- window['{listeners}'][{event}].push({{
337- id: {event_id},
338- windowLabel: {window_label},
339- handler: {handler}
340- }});
330+ "
331+ (function () {{
332+ if (window['{listeners}'] === void 0) {{
333+ Object.defineProperty(window, '{listeners}', {{ value: Object.create(null) }});
334+ }}
335+ if (window['{listeners}'][{event}] === void 0) {{
336+ Object.defineProperty(window['{listeners}'], {event}, {{ value: [] }});
337+ }}
338+ const eventListeners = window['{listeners}'][{event}]
339+ const listener = {{
340+ id: {event_id},
341+ windowLabel: {window_label},
342+ handler: {handler}
343+ }};
344+ if ({event} == 'tauri://window-created') {{
345+ eventListeners.splice(eventListeners.length - 1, 0, listener)
346+ }} else {{
347+ eventListeners.push(listener);
348+ }}
349+ }})()
341350 " ,
342351 listeners = listeners_object_name,
343352 event = event,
You can’t perform that action at this time.
0 commit comments