Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for other windows. #154

Open
JSideris opened this issue Dec 3, 2023 · 1 comment
Open

Support for other windows. #154

JSideris opened this issue Dec 3, 2023 · 1 comment
Assignees

Comments

@JSideris
Copy link
Owner

JSideris commented Dec 3, 2023

Users of the framework should be able to target other windows and write directly to them.

Something like this would be nice

let myWindow = window.open("", "My Popup", "width=500;height=500;");

dot(myWindow.document.body).div("Hello, World!");

The challenge here is that the function for creating elements lies within window.document, and it's a different object for every window. Elements from one window can't be transferred to another.

One option is to set the window based on the target element. We can get the window from the target element using this:

element.ownerDocument.defaultView || element.ownerDocument.parentWindow;

Another problem is components with dynamic elements that phase in and out of existence. Note that components don't use targeters. They just return dot syntax. One option here is to assign a window to the component before the builder is called. Then any new content generated by that component will use it's window. A component could potentially be used in multiple windows. Please test this before marking this as compete.

@JSideris JSideris self-assigned this Dec 3, 2023
@JSideris JSideris moved this to In Progress in DOThtml 6 Dec 12, 2023
@JSideris
Copy link
Owner Author

Solution is you can pass a window object into the target, or as shown above, just choose a target node that's already on the target window. Scheduled to package with v6.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: In Progress
Development

No branches or pull requests

1 participant