Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

fix(form): do not prevent submit when action attribute equals to an empty string #3776

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 1 addition & 1 deletion src/ng/directive/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ var formDirectiveFactory = function(isNgForm) {
compile: function() {
return {
pre: function(scope, formElement, attr, controller) {
if (!attr.action) {
if (!attr.action && attr.action !== '') {
// we can't use jq events because if a form is destroyed during submission the default
// action is not prevented. see #1238
//
Expand Down
4 changes: 2 additions & 2 deletions test/ng/directive/ngEventDirsSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('event directives', function() {
describe('ngSubmit', function() {

it('should get called on form submit', inject(function($rootScope, $compile) {
element = $compile('<form action="" ng-submit="submitted = true">' +
element = $compile('<form ng-submit="submitted = true">' +
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see below

'<input type="submit"/>' +
'</form>')($rootScope);
$rootScope.$digest();
Expand All @@ -29,7 +29,7 @@ describe('event directives', function() {
}
};

element = $compile('<form action="" ng-submit="formSubmission($event)">' +
element = $compile('<form ng-submit="formSubmission($event)">' +
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not right. the point of the test is to simulate conditions when the form is being submitted. which means that we need the action attribute set to something

'<input type="submit"/>' +
'</form>')($rootScope);
$rootScope.$digest();
Expand Down