From bf285d348f56b02846ba484939df20aa2a87a6d4 Mon Sep 17 00:00:00 2001 From: Sam Tsvilik Date: Wed, 20 Feb 2013 19:27:56 -0500 Subject: [PATCH 1/7] jQuery compatible element() selector MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Changing $document.find to angular.element permits more complex selectors when using jQuery. Otherwise you're limited to selecting only by ID's and element tags which is very restricting in the real life testing scenarios. --- src/ngScenario/SpecRunner.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ngScenario/SpecRunner.js b/src/ngScenario/SpecRunner.js index 23cc1dc724e6..a96a3e00247b 100644 --- a/src/ngScenario/SpecRunner.js +++ b/src/ngScenario/SpecRunner.js @@ -117,7 +117,7 @@ angular.scenario.SpecRunner.prototype.addFutureAction = function(name, behavior, angular.forEach(args, function(value, index) { selector = selector.replace('$' + (index + 1), value); }); - var result = $document.find(selector); + var result = angular.element(selector); if (selector.match(NG)) { angular.forEach(['[ng-','[data-ng-','[x-ng-'], function(value, index){ result = result.add(selector.replace(NG, value), $document); From 33c673887741c7a57413884faaee03e8f8f772e7 Mon Sep 17 00:00:00 2001 From: Sam Tsvilik Date: Fri, 3 May 2013 08:45:13 -0300 Subject: [PATCH 2/7] Extending ng-model functionality to hidden fields Hidden fields are still used in hybrid solutions such as MVC.net/etc. and it is valuable to be able to set value of this type of field through ng-model. --- src/ng/directive/input.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ng/directive/input.js b/src/ng/directive/input.js index aaabd1033398..63a65a719928 100644 --- a/src/ng/directive/input.js +++ b/src/ng/directive/input.js @@ -375,7 +375,7 @@ var inputType = { */ 'checkbox': checkboxInputType, - 'hidden': noop, + 'hidden': textInputType, 'button': noop, 'submit': noop, 'reset': noop From 7bb5a0fc6d69ca85f1d1f3daacc575f9aca19e4d Mon Sep 17 00:00:00 2001 From: Sam Tsvilik Date: Thu, 16 May 2013 17:00:45 -0400 Subject: [PATCH 3/7] Extend function fix Extend function of Angular blindly overwrites destination values even if source value is undefined. This fix allows "default" values to remain intact if new value is undefined. --- src/Angular.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Angular.js b/src/Angular.js index 6ea5d1ad2fdf..78b5379bcb5c 100644 --- a/src/Angular.js +++ b/src/Angular.js @@ -233,7 +233,9 @@ function extend(dst) { forEach(arguments, function(obj){ if (obj !== dst) { forEach(obj, function(value, key){ - dst[key] = value; + if(value !== undefined) { + dst[key] = value; + } }); } }); From c0c5d8ed22e871e12bb55c7e926b3b9cec1bfef0 Mon Sep 17 00:00:00 2001 From: Simon Tsvilik Date: Sat, 17 Aug 2013 01:58:25 -0400 Subject: [PATCH 4/7] fix(rootScope.js) - re-applied the fix to the $emit method - improved the the unit test - fixed spacing issue --- src/ng/rootScope.js | 4 +++- test/ng/rootScopeSpec.js | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/ng/rootScope.js b/src/ng/rootScope.js index d94a621d94c6..eba29afa7753 100644 --- a/src/ng/rootScope.js +++ b/src/ng/rootScope.js @@ -836,12 +836,14 @@ function $RootScopeProvider(){ continue; } try { + //allow all listeners attached to the current scope to run namedListeners[i].apply(null, listenerArgs); - if (stopPropagation) return event; } catch (e) { $exceptionHandler(e); } } + //if any listener on the current scope stops propagation, prevent bubbling + if (stopPropagation) return event; //traverse upwards scope = scope.$parent; } while (scope); diff --git a/test/ng/rootScopeSpec.js b/test/ng/rootScopeSpec.js index ddd830881d9b..a64c35e024d8 100644 --- a/test/ng/rootScopeSpec.js +++ b/test/ng/rootScopeSpec.js @@ -922,6 +922,14 @@ describe('Scope', function() { expect(log).toEqual('2>1>0>'); }); + it('should allow all events on the same scope to run even if stopPropagation is called', function(){ + child.$on('myEvent', logger); + grandChild.$on('myEvent', function(e) { e.stopPropagation(); }); + grandChild.$on('myEvent', logger); + grandChild.$on('myEvent', logger); + grandChild.$emit('myEvent'); + expect(log).toEqual('2>2>2>'); + }); it('should dispatch exceptions to the $exceptionHandler', inject(function($exceptionHandler) { From 5e4529442bb5c06eadabd944532846049411042a Mon Sep 17 00:00:00 2001 From: Simon Tsvilik Date: Sat, 17 Aug 2013 10:31:30 -0400 Subject: [PATCH 5/7] Revert "Extend function fix" This reverts commit 7bb5a0fc6d69ca85f1d1f3daacc575f9aca19e4d. --- src/Angular.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Angular.js b/src/Angular.js index c22e8e1e0791..90c7234a33bf 100644 --- a/src/Angular.js +++ b/src/Angular.js @@ -238,9 +238,7 @@ function extend(dst) { forEach(arguments, function(obj){ if (obj !== dst) { forEach(obj, function(value, key){ - if(value !== undefined) { - dst[key] = value; - } + dst[key] = value; }); } }); From 402aac6a2936cf45b2d91cd495641c5490096a7f Mon Sep 17 00:00:00 2001 From: Simon Tsvilik Date: Sat, 17 Aug 2013 10:31:47 -0400 Subject: [PATCH 6/7] Revert "Extending ng-model functionality to hidden fields" This reverts commit 33c673887741c7a57413884faaee03e8f8f772e7. --- src/ng/directive/input.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ng/directive/input.js b/src/ng/directive/input.js index 3e2c7099a0be..6f3919dfb174 100644 --- a/src/ng/directive/input.js +++ b/src/ng/directive/input.js @@ -377,7 +377,7 @@ var inputType = { */ 'checkbox': checkboxInputType, - 'hidden': textInputType, + 'hidden': noop, 'button': noop, 'submit': noop, 'reset': noop From b475b7cc2f466ca9ba1aeae5de9f9f6c8ae2c504 Mon Sep 17 00:00:00 2001 From: Simon Tsvilik Date: Sat, 17 Aug 2013 10:31:55 -0400 Subject: [PATCH 7/7] Revert "jQuery compatible element() selector" This reverts commit bf285d348f56b02846ba484939df20aa2a87a6d4. --- src/ngScenario/SpecRunner.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ngScenario/SpecRunner.js b/src/ngScenario/SpecRunner.js index ec83898c23a4..d15912d91a45 100644 --- a/src/ngScenario/SpecRunner.js +++ b/src/ngScenario/SpecRunner.js @@ -117,7 +117,7 @@ angular.scenario.SpecRunner.prototype.addFutureAction = function(name, behavior, angular.forEach(args, function(value, index) { selector = selector.replace('$' + (index + 1), value); }); - var result = angular.element(selector); + var result = $document.find(selector); if (selector.match(NG)) { angular.forEach(['[ng-','[data-ng-','[x-ng-'], function(value, index){ result = result.add(selector.replace(NG, value), $document);