Opened 7 years ago

Closed 7 years ago

#14891 closed defect (duplicate)

new dijit.form.Button throws "Invalid template" error

Reported by: hbaaron Owned by: hbaaron
Priority: undecided Milestone: tbd
Component: Dijit Version: 1.6.1
Keywords: Cc:
Blocked By: Blocking:


new didjit.form.Button at most pages will success, but not with this page: <you need an account to access this page, though this is a pulic forum. If you need, please contact with me, I already created one>

The issue happens at buildRendering:

node = _4._toDom(this._stringRepl(_19e));

if (node.nodeType != 1) {

throw new Error("Invalid template: " + _19e);


the node type of the returned node is expected to be 1, but actually it's 11. After some tracing, I found the issue caused by a tailing "\r\n" ("\n" if I use google CDN) after the last tag of the template, which actually does not exist in the source code of the template. the tailing "\r\n" then was turned into a text node, so finally the node will contains two nodes, one is a <span> element for the button, the other is a text node. This breaks dijit's specifications.

I'm not sure why and how this tailing "\r\n" was injected, would you please help investigate?

To reproduce this issue: install the extension using the attached package, and then visit page:

An account is needed and if you decide to investigate this issue, please contact with me for the account.

Attachments (1)

sunbox.xpi (194.2 KB) - added by hbaaron 7 years ago.

Download all attachments as: .zip

Change History (5)

Changed 7 years ago by hbaaron

Attachment: sunbox.xpi added


comment:1 Changed 7 years ago by hbaaron

About the extension:

it's an content script try to modify some web pages. Not too much work in the extension though. The mail job of the extension is to inject a Javascript gear.js into the web page, and the gear.js will do the rest job, to create menus, modify web page and etc.

the gear.js will load dojo (1.6.1) from google CDN, itself is loaded from this is my personal website.

comment:2 Changed 7 years ago by bill

Owner: set to hbaaron
Status: newpending

Sorry, but we only investigate problems that have a self-contained reproducible test case, not something where we have to login to a site. If you can provide such a test case then please attach it.

comment:3 Changed 7 years ago by hbaaron

Status: pendingnew

hi bill:

Thanks for read the case. I was unable reproduce the case by myself. I have to use the said URL.

Good news is, I have work around this by set dijit.form.Button.prototype.templateString = dijit.form.Button.prototype.templateString.replace(/(\r\n$|\n$)/g, "");

Now dijit.form.Button can work now. I really don't know how this would happen, so I can't reproduce it by artifical data.

comment:4 Changed 7 years ago by bill

Resolution: duplicate
Status: newclosed

OK, glad you found a workaround. Yes, I don't know how it would happen either, although I agree that the template code is a little bit fragile in that it can be thrown off by whitespace. But that's being tracked in #8494, so I'll close this one as a duplicate.

Last edited 7 years ago by bill (previous) (diff)
Note: See TracTickets for help on using tickets.