Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#15871 closed defect (fixed)

[regression] Parser fails if dijit/form/Form contains dijit/form/* before a script dojo/* regression in 1.8.0

Reported by: Magnus Lidbom Owned by: bill
Priority: undecided Milestone: 1.8.1
Component: Parser Version: 1.8.0
Keywords: Cc: Kitson Kelly
Blocked By: Blocking:

Description

This causes an exception

<!DOCTYPE html>
<html>
<head>
    <script src="http://ajax.googleapis.com/ajax/libs/dojo/1.8.0/dojo/dojo.js"></script>
    <script type="text/javascript">
        require([
            "dojo/parser",
            "dijit/form/CheckBox",
            "dijit/form/Form"], function (parser) {
                parser.parse();
            });
    </script>
</head>

<body class="claro">
    <form action="/SomeUrl" data-dojo-type="dijit/form/Form">
        <input data-dojo-type="dijit/form/CheckBox" name="ACheckBox" />
        <script type="dojo/on" data-dojo-event="click">
        </script>
    </form>
</body>
</html>

Error: An attempt was made to reference a Node in a context where it does not exist.
    at Object._1a.construct (http://ajax.googleapis.com/ajax/libs/dojo/1.8.0/dojo/parser.js:8:4772)
    at Object.<anonymous> (http://ajax.googleapis.com/ajax/libs/dojo/1.8.0/dojo/parser.js:8:1939)
    at Object._578.map (http://ajax.googleapis.com/ajax/libs/dojo/1.8.0/dojo/dojo.js:15:141657)
    at Object._1a._instantiate (http://ajax.googleapis.com/ajax/libs/dojo/1.8.0/dojo/parser.js:8:1785)
    at _1a.parse (http://ajax.googleapis.com/ajax/libs/dojo/1.8.0/dojo/parser.js:8:9006)
    at _4b8 (http://ajax.googleapis.com/ajax/libs/dojo/1.8.0/dojo/dojo.js:15:122572)
    at Promise._4b7.then._4c5.then (http://ajax.googleapis.com/ajax/libs/dojo/1.8.0/dojo/dojo.js:15:124391)
    at Object._1a.parse (http://ajax.googleapis.com/ajax/libs/dojo/1.8.0/dojo/parser.js:8:8961)
    at file:///C:/Manpower/DojoParserError.html:10:24
    at _c5 (http://ajax.googleapis.com/ajax/libs/dojo/1.8.0/dojo/dojo.js:15:11308)

As far as I could tell, debugging with the non-CDN version, the parser tries to access the script tag as if it was contained in the input tag rather than the form tag.

If I put the script tag before the input tag it works. If I put the input tag in a div it works.

Change History (9)

comment:1 Changed 7 years ago by bill

Resolution: invalid
Status: newclosed

You need to wrap the parser.parse() call in a call to dojo/ready.

require(["dojo/parser", "dojo/ready"], function(parser, ready){
  ready(function(){
    parser.parse();
  });
});

comment:2 Changed 7 years ago by Magnus Lidbom

First: kudos on the efficient bug wrangling. My apologies about the messed up repro.

Unfortunately I only messed up the repro in the last stages of isolating the issue to something I could easily post here. The code below fails as I described. Originally I used dojo/domReady! and it fails in the same way.

Please reopen.

<!DOCTYPE html>
<html>
<head>
    <script src="http://ajax.googleapis.com/ajax/libs/dojo/1.8.0/dojo/dojo.js"></script>
    <script type="text/javascript">
        require([
           "dojo/parser",
           "dojo/ready",
           "dijit/form/CheckBox",
           "dijit/form/Form"], function (parser, ready) {
              ready(function(){
                 parser.parse();
              });
           });
    </script>
</head>

<body class="claro">
    <form action="/SomeUrl" data-dojo-type="dijit/form/Form">
      <input data-dojo-type="dijit/form/CheckBox" name="ACheckBox" />
      <script type="dojo/on" data-dojo-event="click">
      </script>  
    </form>
</body>
</html>

comment:3 Changed 7 years ago by bill

Resolution: invalid
Status: closedreopened

Ah I see, OK, makes sense.

comment:4 Changed 7 years ago by bill

Milestone: tbd1.8.1
Summary: Parser fails if dijit/form/Form contains dijit/form/* before a script dojo/* regression in 1.8.0[regression[ Parser fails if dijit/form/Form contains dijit/form/* before a script dojo/* regression in 1.8.0

Regressed in [28469].

comment:5 Changed 7 years ago by bill

Cc: Kitson Kelly added
Summary: [regression[ Parser fails if dijit/form/Form contains dijit/form/* before a script dojo/* regression in 1.8.0[regression] Parser fails if dijit/form/Form contains dijit/form/* before a script dojo/* regression in 1.8.0

comment:6 Changed 7 years ago by bill

Resolution: fixed
Status: reopenedclosed

In [29526]:

Fix bug collecting <script>'s that appear after normal child nodes. Issue was with unwinding the stack (ie, moving from a child to the parent). Fixes #15871 on trunk/ !strict.

comment:7 Changed 7 years ago by bill

In [29527]:

Fix bug collecting <script>'s that appear after normal child nodes. Issue was with unwinding the stack (ie, moving from a child to the parent). Fixes #15871 on 1.8/ branch !strict.

comment:8 Changed 7 years ago by bill

In [29539]:

If there's an DOMNode with id="on", don't get confused into thinking that window.on() is a function you can call. Fixes #15888, refs #15871 on trunk !strict.

comment:9 Changed 7 years ago by bill

In [29540]:

If there's an DOMNode with id="on", don't get confused into thinking that window.on() is a function you can call. Fixes #15888, refs #15871 on 1.8 branch !strict.

Note: See TracTickets for help on using tickets.