Opened 10 years ago

Closed 10 years ago

#13747 closed defect (fixed)

host-browser feature detection broken

Reported by: haysmark Owned by: Rawld Gill
Priority: high Milestone: 1.7
Component: Loader Version: 1.6.1
Keywords: Cc:
Blocked By: Blocking:


In the latest node.js, I am getting an error when I run dojo.js:

C:\Users\IBM_ADMIN\IBM\dojo>node dojo/dojo.js

        throw e; // process.nextTick error, or 'error' event on first tick
TypeError: Cannot read property 'addEventListener' of undefined
    at C:\Users\IBM_ADMIN\IBM\dojo\dojo\dojo.js:247:65
    at Object.<anonymous> (C:\Users\IBM_ADMIN\IBM\dojo\dojo\dojo.js:1643:2)
    at Module._compile (module.js:416:26)
    at Object..js (module.js:434:10)
    at Module.load (module.js:335:31)
    at Function._load (module.js:294:12)
    at Array.<anonymous> (module.js:454:10)
    at EventEmitter._tickCallback (node.js:197:26)

Indeed if I go to line 247 in dojo.js I see this check:

has.add("dojo-force-activex-xhr", has("host-browser") && !doc.addEventListener && window.location.protocol == "file:");

Debugging reveals that has("host-browser") returns true, but the doc variable is undefined. As a console application, I don't think node.js is meant to "have" host-browser.

Change History (5)

comment:1 Changed 10 years ago by haysmark

Here is my has:

{ [Function]
   { 'host-browser': 1,
     dom: 1,
     'dojo-amd-factory-scan': 1,
     'dojo-loader': 1,
     'dojo-has-api': 1,
     'dojo-inject-api': 1,
     'dojo-timeout-api': 1,
     'dojo-trace-api': 1,
     'dojo-log-api': 1,
     'dojo-dom-ready-api': 1,
     'dojo-publish-privates': 1,
     'dojo-config-api': 1,
     'dojo-sniff': 1,
     'dojo-sync-loader': 1,
     'dojo-test-sniff': 1,
     'dojo-1x-base': 1,
     'config-tlmSiblingOfDojo': 1,
     'host-node': false,
     'host-rhino': false,
     'dojo-combo-api': undefined },
  add: [Function] }

Why isn't host-node true?

comment:2 Changed 10 years ago by haysmark

That was a rhetorical question, here is why host-node is false:

has.add("host-node", typeof process == "object" && /\/node/.test(process.execPath));

Did you know you can run node on Windows? This causes the exec path to contain backslashes, so actually the bug is in the host-node logic. I take it host-browser will be unset when this bug is fixed.

comment:3 Changed 10 years ago by Rawld Gill

Resolution: fixed
Status: newclosed

In [26339]:

improved node.js detection for windows hosts; fixes #13747; !strict

comment:4 Changed 10 years ago by haysmark

Resolution: fixed
Status: closedreopened

Getting there, now I'm getting:

TypeError: Cannot read property '1' of null
    at Object.config (C:\Users\IBM_ADMIN\IBM\dojo\dojo\_base\configNode.js:48:4
    at C:\Users\IBM_ADMIN\IBM\dojo\dojo\dojo.js:148:36

It looks like there are more forward slash assumptions in configNode at line 48:

// reset some configuration switches with node-appropriate values
	var nodeConfig = {
		baseUrl: __dirname.match(/(.+)\/_base$/)[1],

comment:5 Changed 10 years ago by haysmark

Resolution: fixed
Status: reopenedclosed

In [26371]:

Fix node and rhino. Fixes #13747.

Note: See TracTickets for help on using tickets.