Opened 5 years ago

Closed 5 years ago

#9903 closed defect (invalid)

dojo.create with "class" attribute fails in IE

Reported by: olore Owned by: anonymous
Priority: high Milestone: tbd
Component: General Version: 1.3.2
Keywords: Cc:
Blocked by: Blocking:

Description

Setting "class" via dojo.attr works (see workarond below) as was fixed in #6957, however dojo.create with a "class" attribute fails with "Expected identifier, string or number"

Bug:

                function bug() {
                        var node = dojo.create("div", {
                                id: "mytest"
                                , class: "myclass" //Results in "Expected identifier, string or number"
                                , innerHTML : 'Test 123'
                        });
                        alert("this won't alert in IE6");
                }

Workaround:

                function workaround() {
                        var node = dojo.create("div", {
                                id: "mytest"
                                , innerHTML : 'Test 123'
                        });
                        //set "class" via dojo.attr
                        dojo.attr(node, "class", "myclass");
                        alert("worked!");
                }

Change History (1)

comment:1 Changed 5 years ago by dante

  • Resolution set to invalid
  • Status changed from new to closed

class is a reserved word, and IE throws that error anytime it encounters the word class unquoted. Because of this, if you use className:"foo" your test [should] work. (className is the appropriate attribute to set for class="" values.) other reserved words IE dies on: "for", "default", "float" to name a couple.

Note: See TracTickets for help on using tickets.