Explicitly ban some names for Templates.

Fixes the test failure on IEs because for IEs 'name' is not a magical property
on functions.
This commit is contained in:
Slava Kim
2014-10-09 15:22:19 -07:00
parent 000af3ad2e
commit ce98ea08d5

View File

@@ -8,9 +8,15 @@
*/
Template = Blaze.Template;
var RESERVED_TEMPLATE_NAMES = "__proto__ name".split(" ");
// Check for duplicate template names and illegal names that won't work.
Template.__checkName = function (name) {
if (name in Template) {
// Some names can't be used for Templates. These include:
// - Properties Blaze sets on the Template object.
// - Properties that some browsers don't let the code to set.
// These are specified in RESERVED_TEMPLATE_NAMES.
if (name in Template || RESERVED_TEMPLATE_NAMES.indexOf(name) !== -1) {
if ((Template[name] instanceof Template) && name !== "body")
throw new Error("There are multiple templates named '" + name + "'. Each template needs a unique name.");
throw new Error("This template name is reserved: " + name);