mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-11 12:20:22 +00:00
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. git-svn-id: https://develop.svn.wordpress.org/trunk@54241 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -36,6 +36,9 @@ window.wp = window.wp || {};
|
||||
};
|
||||
|
||||
return function ( data ) {
|
||||
if ( ! document.getElementById( 'tmpl-' + id ) ) {
|
||||
throw new Error( 'Template not found: ' + '#tmpl-' + id );
|
||||
}
|
||||
compiled = compiled || _.template( $( '#tmpl-' + id ).html(), options );
|
||||
return compiled( data );
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user