WordPress.org

Make WordPress Core

Opened 3 years ago

Last modified 5 months ago

#36631 new enhancement

wp.template() should throw an error if the template is not found

Reported by: joehoyle Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: General Keywords: has-patch 2nd-opinion
Focuses: javascript Cc:
PR Number:

Description

When calling wp.template() in JS, if the template element does not exist (maybe you forgot to wait for document.ready) a very cryptic error happens ("Uncaught TypeError: Cannot read property 'replace' of undefined"). I'm not totally familiar with how defensive we typically are for things like this - but in this case it would have saved me a good deal of effort if I saw a descriptive error.

Attachments (1)

36631.diff (506 bytes) - added by joehoyle 3 years ago.

Download all attachments as: .zip

Change History (1)

@joehoyle
3 years ago

Note: See TracTickets for help on using tickets.