Skip to content

Conversation

@karlseguin
Copy link
Collaborator

On page load, emitted by the page, the target is the window, but it's improperly cast since the pointer is actually window.base. This is going to be a problem in general for any Zig type dispatched as a target, but the Window one is the most obvious and the easiest to fix. If this issue comes up with other types, we'll need to come up with a more robust solution.

On page load, emitted by the page, the target is the window, but it's improperly
cast since the pointer is actually `window.base`. This is going to be a problem
in general for any Zig type dispatched as a target, but the Window one is the
most obvious and the easiest to fix. If this issue comes up with other types,
we'll need to come up with a more robust solution.
// Ideally, we'd remove this duality. Failing that, we'll need to embed
// data into the *parser.EventTarget should we need this for other types.
// For now, for the Window, which is a singleton, we can do this:
if (@intFromPtr(et) == @intFromPtr(&page.window.base)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally I would make every struct a extern struct and ban struct.
Would also help with slowly taking over libDOM functionality.
IMO zig got the default wrong in this case.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm...I was going to say "I don't want to make that decision".

Then I thought, "well, we could at least do it on Window for this specific problem...try it out".

But ya..no. There's a bunch of restrictions on what you can put into an extern struct. You can't, for example, have slices. So target: []const u8 = "", isn't valid.

If this is the way we go, it's a bigger change / discussion.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh my😱

@karlseguin karlseguin merged commit fff0a8a into main Jun 4, 2025
11 checks passed
@karlseguin karlseguin deleted the window_target_crash branch June 4, 2025 23:56
@github-actions github-actions bot locked and limited conversation to collaborators Jun 4, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants