Skip to content
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

fix deprecated event.returnValue in Chrome #1429

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions build/event-base/event-base-coverage.js

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions build/event-base/event-base-debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,11 @@ Y.extend(DOMEventFacade, Object, {

preventDefault: function(returnValue) {
var e = this._event;
e.preventDefault();
e.returnValue = returnValue || false;
if (e.preventDefault) {
e.preventDefault();
} else {
e.returnValue = returnValue || false;
}
this._wrapper.prevented = 1;
this.prevented = 1;
},
Expand Down
4 changes: 2 additions & 2 deletions build/event-base/event-base-min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions build/event-base/event-base.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,11 @@ Y.extend(DOMEventFacade, Object, {

preventDefault: function(returnValue) {
var e = this._event;
e.preventDefault();
e.returnValue = returnValue || false;
if (e.preventDefault) {
e.preventDefault();
} else {
e.returnValue = returnValue || false;
}
this._wrapper.prevented = 1;
this.prevented = 1;
},
Expand Down
7 changes: 5 additions & 2 deletions src/event/js/event-facade-dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,11 @@ Y.extend(DOMEventFacade, Object, {

preventDefault: function(returnValue) {
var e = this._event;
e.preventDefault();
e.returnValue = returnValue || false;
if (e.preventDefault) {
e.preventDefault();
Copy link
Contributor

Choose a reason for hiding this comment

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

The logic here seems a bit flawed. Prior to your change, e.preventDefault was invoked without checking if said method actually existed. Therefore, your additional if statement will always evaluate to true.

preventDefault is manually attached to the Event object somewhere along the line...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are right.
Sorry, I misunderstanded the code here, I have doubted why we have returnValue and preventDefault at the same time. Seems we set returnValue property here for other use which I am not familiar, and the preventDefault is always exist.

I will reread relative code,thanks for explaning.

} else {
e.returnValue = returnValue || false;
Copy link
Contributor

Choose a reason for hiding this comment

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

The || false is unnecessary.

}
this._wrapper.prevented = 1;
this.prevented = 1;
},
Expand Down