Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#11257 closed defect (fixed)

[patch][ccla]Calling dojo.hash(blah, true) causes duplicate /dojo/hashchange published

Reported by: Nick Fenwick Owned by: Rob Retchless
Priority: high Milestone: 1.5.1
Component: Core Version: 1.4.3
Keywords: dojo.hash.hashchange.duplicate Cc:
Blocked By: Blocking:

Description

Firefox 3.6.3, dojo 1.4.3.

When I call dojo.hash("foo", true) I find that two /dojo/hashchange events are published. My subscriber is called twice.

I'll attach a simple html example file. It uses Google 1.4 CDN, and I've seen similar behaviour on 1.4.3 local build.

SVN trunk code looks very similar to 1.4.3, I haven't not tested against 1.5.x but I suspect the same behaviour will hold there too.

The problem seems related to calling _pollLocation from _replace (which is only called when true is passed in hash() 2nd argument). _pollLocation it not set up by hash.js addOnLoad in certain circumstances.

If I change the hash.js:_replace() fn with a block around its call to _pollLocation at the end, the problem goes away:

location.replace("#"+hash);

if("onhashchange" in dojo.global && (!dojo.isIE
(dojo.isIE >= 8 && document.compatMode != "BackCompat?"))) {

console.log("RRRRRRRRRRRRReplace not calling _pollLocation");

} else {

console.log("RRRRRRRRRRRRReplace calling _pollLocation"); _pollLocation();

}

Can someone confirm this is a real problem, or me misusing dojo.hash somehow?

Attachments (2)

hashrepeatedpublish.html (1.6 KB) - added by Nick Fenwick 9 years ago.
Test html file demonstrating repeated /dojo/hashchange events.
hash.patch (977 bytes) - added by Adam Peller 9 years ago.
patch from Rob Retchless (IBM, CCLA)

Download all attachments as: .zip

Change History (15)

Changed 9 years ago by Nick Fenwick

Attachment: hashrepeatedpublish.html added

Test html file demonstrating repeated /dojo/hashchange events.

comment:1 Changed 9 years ago by Nick Fenwick

Sorry, my code got slightly obliterated. Again:

		location.replace("#"+hash);
		if("onhashchange" in dojo.global && (!dojo.isIE || (dojo.isIE >= 8 && document.compatMode != "BackCompat"))) {
			console.log("RRRRRRRRRRRRReplace not calling _pollLocation");
		} else {
			console.log("RRRRRRRRRRRRReplace calling _pollLocation");
			_pollLocation();
		}

The 'if' logic is simply copied from the addOnLoad code in hash.js.

comment:2 Changed 9 years ago by Adam Peller

Owner: changed from anonymous to Rob Retchless

comment:3 Changed 9 years ago by James Burke

Milestone: tbd1.6

retchless: any comment? I am moving this to 1.6, but we can move it into 1.5 if we can get it done this week.

comment:4 Changed 9 years ago by Rob Retchless

@neek, Thanks for the great bug report!

@jburke, I'll work on a patch for 1.5.

comment:5 Changed 9 years ago by James Burke

Milestone: 1.61.5

comment:6 Changed 9 years ago by Adam Peller

Milestone: 1.51.5.1

Changed 9 years ago by Adam Peller

Attachment: hash.patch added

patch from Rob Retchless (IBM, CCLA)

comment:7 Changed 9 years ago by Nick Fenwick

@retchless: np :)

I just applied the patch (manually) to the still broken 1.5.0, and it works. Please schedule for 1.5.1 if possible.

comment:8 Changed 9 years ago by Adam Peller

Summary: Calling dojo.hash(blah, true) causes duplicate /dojo/hashchange published[patch][ccla]Calling dojo.hash(blah, true) causes duplicate /dojo/hashchange published

comment:9 Changed 9 years ago by bill

Milestone: 1.5.1tbd

There will be no 1.5.1.

comment:10 Changed 9 years ago by Adam Peller

That's not true. There just hasn't been one yet. I'd encourage you to check the fix into the 1.5 branch if it would be appropriate for a 1.5.x release.

comment:11 Changed 9 years ago by Adam Peller

Milestone: tbd1.5.1

changing back to 1.5.1 by request

comment:12 Changed 9 years ago by Adam Peller

Resolution: fixed
Status: newclosed

(In [23595]) patch from retchless \!strict fixes #11257

comment:13 Changed 9 years ago by Adam Peller

(In [23596]) patch from retchless \!strict fixes #11257

Note: See TracTickets for help on using tickets.