Skip to content

Update upstream #41

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Dec 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,16 +186,6 @@ module.exports = function(grunt) {
},

build: {
scenario: {
dest: 'build/angular-scenario.js',
src: [
'bower_components/jquery/dist/jquery.js',
util.wrap([files['angularSrc'], files['angularScenario']], 'ngScenario/angular')
],
styles: {
css: ['css/angular.css', 'css/angular-scenario.css']
}
},
angular: {
dest: 'build/angular.js',
src: util.wrap([files['angularSrc']], 'angular'),
Expand Down Expand Up @@ -281,9 +271,7 @@ module.exports = function(grunt) {
files: [
'src/**/*.js',
'test/**/*.js',
'!test/ngScenario/DescribeSpec.js',
'!src/ng/directive/attrs.js', // legitimate xit here
'!src/ngScenario/**/*.js',
'!test/helpers/privateMocks*.js'
],
options: {
Expand Down
27 changes: 0 additions & 27 deletions angularFiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,26 +153,8 @@ var angularFiles = {
]
},

'angularScenario': [
'src/ngScenario/Scenario.js',
'src/ngScenario/Application.js',
'src/ngScenario/Describe.js',
'src/ngScenario/Future.js',
'src/ngScenario/ObjectModel.js',
'src/ngScenario/Runner.js',
'src/ngScenario/SpecRunner.js',
'src/ngScenario/dsl.js',
'src/ngScenario/matchers.js',
'src/ngScenario/output/Html.js',
'src/ngScenario/output/Json.js',
'src/ngScenario/output/Xml.js',
'src/ngScenario/output/Object.js'
],

'angularTest': [
'test/helpers/*.js',
'test/ngScenario/*.js',
'test/ngScenario/output/*.js',
'test/*.js',
'test/auto/*.js',
'test/ng/**/*.js',
Expand All @@ -193,22 +175,15 @@ var angularFiles = {
'test/jquery_remove.js',
'@angularSrc',
'@angularSrcModules',
'@angularScenario',
'@angularTest'
],

'karmaExclude': [
'test/jquery_alias.js',
'src/angular-bootstrap.js',
'src/ngScenario/angular-bootstrap.js',
'src/angular.bind.js'
],

'karmaScenario': [
'build/angular-scenario.js',
'build/docs/docs-scenario.js'
],

'karmaModules': [
'build/angular.js',
'@angularSrcModules',
Expand All @@ -231,13 +206,11 @@ var angularFiles = {
'test/jquery_alias.js',
'@angularSrc',
'@angularSrcModules',
'@angularScenario',
'@angularTest'
],

'karmaJqueryExclude': [
'src/angular-bootstrap.js',
'src/ngScenario/angular-bootstrap.js',
'test/jquery_remove.js',
'src/angular.bind.js'
]
Expand Down
22 changes: 0 additions & 22 deletions docs/content/error/$rootScope/inevt.ngdoc

This file was deleted.

6 changes: 0 additions & 6 deletions docs/content/guide/e2e-testing.ngdoc
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@

# E2E Testing

<div class="alert alert-danger">
**Note:** In the past, end-to-end testing could be done with a deprecated tool called
[AngularJS Scenario Runner](http://code.angularjs.org/1.2.16/docs/guide/e2e-testing). That tool
is now in maintenance mode.
</div>

As applications grow in size and complexity, it becomes unrealistic to rely on manual testing to
verify the correctness of new features, catch bugs and notice regressions. Unit tests
are the first line of defense for catching bugs, but sometimes issues come up with integration
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@
"karma-firefox-launcher": "^1.0.1",
"karma-jasmine": "^1.1.0",
"karma-junit-reporter": "^1.2.0",
"karma-ng-scenario": "^1.0.0",
"karma-sauce-launcher": "^1.2.0",
"karma-script-launcher": "^1.0.0",
"karma-spec-reporter": "^0.0.31",
Expand Down
1 change: 0 additions & 1 deletion src/ng/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ function Browser(window, document, $log, $sniffer) {

/**
* @private
* Note: this method is used only by scenario runner
* TODO(vojta): prefix this method with $$ ?
* @param {function()} callback Function that will be called when no outstanding request
*/
Expand Down
45 changes: 32 additions & 13 deletions src/ng/directive/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ var nullFormCtrl = {
$setValidity: noop,
$setDirty: noop,
$setPristine: noop,
$setSubmitted: noop
$setSubmitted: noop,
$$setSubmitted: noop
},
PENDING_CLASS = 'ng-pending',
SUBMITTED_CLASS = 'ng-submitted';
Expand Down Expand Up @@ -274,12 +275,25 @@ FormController.prototype = {
* @name form.FormController#$setSubmitted
*
* @description
* Sets the form to its submitted state.
* Sets the form to its `$submitted` state. This will also set `$submitted` on all child and
* parent forms of the form.
*/
$setSubmitted: function() {
var rootForm = this;
while (rootForm.$$parentForm && (rootForm.$$parentForm !== nullFormCtrl)) {
rootForm = rootForm.$$parentForm;
}
rootForm.$$setSubmitted();
},

$$setSubmitted: function() {
this.$$animate.addClass(this.$$element, SUBMITTED_CLASS);
this.$submitted = true;
this.$$parentForm.$setSubmitted();
forEach(this.$$controls, function(control) {
if (control.$$setSubmitted) {
control.$$setSubmitted();
}
});
}
};

Expand Down Expand Up @@ -338,16 +352,21 @@ addSetValidityMethod({
* @restrict EAC
*
* @description
* Nestable alias of {@link ng.directive:form `form`} directive. HTML
* does not allow nesting of form elements. It is useful to nest forms, for example if the validity of a
* sub-group of controls needs to be determined.
*
* Note: the purpose of `ngForm` is to group controls,
* but not to be a replacement for the `<form>` tag with all of its capabilities
* (e.g. posting to the server, ...).
*
* @param {string=} ngForm|name Name of the form. If specified, the form controller will be published into
* related scope, under this name.
* Helper directive that makes it possible to create control groups inside a
* {@link ng.directive:form `form`} directive.
* These "child forms" can be used, for example, to determine the validity of a sub-group of
* controls.
*
* <div class="alert alert-danger">
* **Note**: `ngForm` cannot be used as a replacement for `<form>`, because it lacks its
* [built-in HTML functionality](https://html.spec.whatwg.org/#the-form-element).
* Specifically, you cannot submit `ngForm` like a `<form>` tag. That means,
* you cannot send data to the server with `ngForm`, or integrate it with
* {@link ng.directive:ngSubmit `ngSubmit`}.
* </div>
*
* @param {string=} ngForm|name Name of the form. If specified, the form controller will
* be published into the related scope, under this name.
*
*/

Expand Down
2 changes: 0 additions & 2 deletions src/ng/location.js
Original file line number Diff line number Diff line change
Expand Up @@ -938,8 +938,6 @@ function $LocationProvider() {
// update location manually
if ($location.absUrl() !== $browser.url()) {
$rootScope.$apply();
// hack to work around FF6 bug 684208 when scenario runner clicks on links
$window.angular['ff-684208-preventDefault'] = true;
}
}
}
Expand Down
82 changes: 48 additions & 34 deletions src/ng/rootScope.js
Original file line number Diff line number Diff line change
Expand Up @@ -1271,14 +1271,13 @@ function $RootScopeProvider() {

var self = this;
return function() {
var index = arrayRemove(namedListeners, listener);
if (index >= 0) {
var indexOfListener = namedListeners.indexOf(listener);
if (indexOfListener !== -1) {
// Use delete in the hope of the browser deallocating the memory for the array entry,
// while not shifting the array indexes of other listeners.
// See issue https://github.com/angular/angular.js/issues/16135
delete namedListeners[indexOfListener];
decrementListenerCount(self, 1, name);
// We are removing a listener while iterating over the list of listeners.
// Update the current $$index if necessary to ensure no listener is skipped.
if (index <= namedListeners.$$index) {
namedListeners.$$index--;
}
}
};
},
Expand Down Expand Up @@ -1307,7 +1306,9 @@ function $RootScopeProvider() {
* @return {Object} Event object (see {@link ng.$rootScope.Scope#$on}).
*/
$emit: function(name, args) {
var scope = this,
var empty = [],
namedListeners,
scope = this,
stopPropagation = false,
event = {
name: name,
Expand All @@ -1318,11 +1319,28 @@ function $RootScopeProvider() {
},
defaultPrevented: false
},
listenerArgs = concat([event], arguments, 1);
listenerArgs = concat([event], arguments, 1),
i, length;

do {
invokeListeners(scope, event, listenerArgs, name);

namedListeners = scope.$$listeners[name] || empty;
event.currentScope = scope;
for (i = 0, length = namedListeners.length; i < length; i++) {

// if listeners were deregistered, defragment the array
if (!namedListeners[i]) {
namedListeners.splice(i, 1);
i--;
length--;
continue;
}
try {
//allow all listeners attached to the current scope to run
namedListeners[i].apply(null, listenerArgs);
} catch (e) {
$exceptionHandler(e);
}
}
//if any listener on the current scope stops propagation, prevent bubbling
if (stopPropagation) {
break;
Expand Down Expand Up @@ -1373,11 +1391,28 @@ function $RootScopeProvider() {

if (!target.$$listenerCount[name]) return event;

var listenerArgs = concat([event], arguments, 1);
var listenerArgs = concat([event], arguments, 1),
listeners, i, length;

//down while you can, then up and next sibling or up and next sibling until back at root
while ((current = next)) {
invokeListeners(current, event, listenerArgs, name);
event.currentScope = current;
listeners = current.$$listeners[name] || [];
for (i = 0, length = listeners.length; i < length; i++) {
// if listeners were deregistered, defragment the array
if (!listeners[i]) {
listeners.splice(i, 1);
i--;
length--;
continue;
}

try {
listeners[i].apply(null, listenerArgs);
} catch (e) {
$exceptionHandler(e);
}
}

// Insanity Warning: scope depth-first traversal
// yes, this code is a bit crazy, but it works and we have tests to prove it!
Expand Down Expand Up @@ -1408,27 +1443,6 @@ function $RootScopeProvider() {

return $rootScope;

function invokeListeners(scope, event, listenerArgs, name) {
var listeners = scope.$$listeners[name];
if (listeners) {
if (listeners.$$index !== undefined) {
throw $rootScopeMinErr('inevt', '{0} already $emit/$broadcast-ing on scope ({1})', name, scope.$id);
}
event.currentScope = scope;
try {
for (listeners.$$index = 0; listeners.$$index < listeners.length; listeners.$$index++) {
try {
//allow all listeners attached to the current scope to run
listeners[listeners.$$index].apply(null, listenerArgs);
} catch (e) {
$exceptionHandler(e);
}
}
} finally {
listeners.$$index = undefined;
}
}
}

function beginPhase(phase) {
if ($rootScope.$$phase) {
Expand Down
Loading