Make WordPress Core

Opened 6 years ago

Last modified 21 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 needs-refresh
Focuses: javascript Cc:


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 6 years ago.

Download all attachments as: .zip

Change History (3)

6 years ago

This ticket was mentioned in Slack in #core by talldanwp. View the logs.

21 months ago

#2 @noisysocks
21 months ago

  • Keywords needs-refresh added

Good suggestion @joehoyle! The patch doesn't apply cleanly anymore, but if you or someone else is happy to refresh it then I think let's get this in.

Note: See TracTickets for help on using tickets.