Make WordPress Core

Changeset 54241

Timestamp:
09/20/2022 03:50:40 AM (22 months ago)
Author:
desrosj
Message:

General: Throw a more descriptive error when templates are not found.

When wp.template() is called in JavaScript for a template element that does not exist, a very nondescript error message is currently returned (“Uncaught TypeError: Cannot read property replace of undefined”).

This updates adds a check for this scenario and a new “Template not found” error is now thrown instead.

Props joehoyle, noisysocks, hilayt24.
Fixes #36631.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/js/_enqueues/wp/util.js

    r51238 r54241  
    3737
    3838        return function ( data ) {
     39
     40
     41
    3942            compiled = compiled || _.template( $( '#tmpl-' + id ).html(),  options );
    4043            return compiled( data );
Note: See TracChangeset for help on using the changeset viewer.