Skip to content

Conversation

@draganescu
Copy link
Contributor

@draganescu draganescu commented Aug 30, 2025

Motivation for the change, related issues

We use playground as a preview tool inside an app that generates WordPress blocks via AI assistant. We encounter JavaScript Error: TypeError: e.target.closest is not a function coming from Playground and it encumbers our assisted error recovery because it comes from outside of the generated code.

Implementation details

We don't attempt to update the link if the element surprisingly doesn't have a closest method (which is why we also log the element to see why this happens)

Testing Instructions (or ideally a Blueprint)

Hard to figure out, sometimes it occurs.

@adamziel
Copy link
Collaborator

Turns out e.target is of type EventTarget that also covers Document, Window, and other data types without the .closest() method – see MDN. I've removed the console log and documented the guard.

@adamziel adamziel merged commit ef999c5 into WordPress:trunk Aug 30, 2025
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants