WordPress.org

Make WordPress Core

Opened 4 years ago

Last modified 3 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:

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

Download all attachments as: .zip

Change History (3)

@joehoyle
4 years ago

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


3 months ago

#2 @noisysocks
3 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.