[Pkg-javascript-commits] [dojo] 77/149: refs #18155, fix aspect nextId when running multiple versions of Dojo in the same app

David Prévot taffit at moszumanska.debian.org
Sat Feb 27 03:13:49 UTC 2016


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository dojo.

commit a221e6e801a9f03b9494ed7aa06351605c1fc676
Author: Benjamin Santalucia <ben at dojotoolkit-fr.org>
Date:   Fri Sep 11 13:04:07 2015 -0700

    refs #18155, fix aspect nextId when running multiple versions of Dojo in the same app
---
 aspect.js            |  7 ++++---
 tests/unit/aspect.js | 27 +++++++++++++++++++++++++++
 2 files changed, 31 insertions(+), 3 deletions(-)

diff --git a/aspect.js b/aspect.js
index a3af7c6..e136a65 100644
--- a/aspect.js
+++ b/aspect.js
@@ -4,7 +4,7 @@ define([], function(){
 	//		dojo/aspect
 
 	"use strict";
-	var undefined, nextId = 0;
+	var undefined;
 	function advise(dispatcher, type, advice, receiveArguments){
 		var previous = dispatcher[type];
 		var around = type == "around";
@@ -49,7 +49,7 @@ define([], function(){
 						dispatcher = advice = signal.advice = null;
 					}
 				},
-				id: nextId++,
+				id: dispatcher.nextId++,
 				advice: advice,
 				receiveArguments: receiveArguments
 			};
@@ -79,7 +79,7 @@ define([], function(){
 			if(!existing || existing.target != target){
 				// no dispatcher in place
 				target[methodName] = dispatcher = function(){
-					var executionId = nextId;
+					var executionId = dispatcher.nextId;
 					// before advice
 					var args = arguments;
 					var before = dispatcher.before;
@@ -115,6 +115,7 @@ define([], function(){
 					}};
 				}
 				dispatcher.target = target;
+				dispatcher.nextId = dispatcher.nextId || 0;
 			}
 			var results = advise((dispatcher || existing), type, advice, receiveArguments);
 			advice = null;
diff --git a/tests/unit/aspect.js b/tests/unit/aspect.js
index eeca012..337c74c 100644
--- a/tests/unit/aspect.js
+++ b/tests/unit/aspect.js
@@ -78,6 +78,33 @@ define([
 			},
 
 			'.after': {
+				'multiple dojo version': function() {
+					var aspectAfterCount = 0;
+					require({
+						packages: [
+							{ name: 'dojo1', location: './' },
+							{ name: 'dojo2', location: './' }
+						]
+					}, ['dojo1/aspect', 'dojo2/aspect'], this.async().callback(function(aspectOne, aspectTwo) {
+						//empty function to aspect on
+						var target = {};
+						target.onclick = function() {};
+						
+						aspectOne.after(target, 'onclick', function() {
+							aspectAfterCount++;
+						});
+						aspectTwo.after(target, 'onclick', function() {
+							aspectAfterCount++;
+						});
+						aspectTwo.after(target, 'onclick', function() {
+							aspectAfterCount++;
+						});
+		
+						target.onclick();
+						
+						assert.equal(aspectAfterCount, 3);
+					}));
+				},
 				'overriding return value from original method': function () {
 					var expected = 'override!';
 					var aspectSpy = sinon.stub().returns(expected);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/dojo.git



More information about the Pkg-javascript-commits mailing list