A Pen by Andrew Kirchmyer on CodePen.
Created
November 17, 2013 04:04
-
-
Save akirchmyer/7508995 to your computer and use it in GitHub Desktop.
A Pen by Andrew Kirchmyer.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Stopping event continuation can be hidden behind a facade | |
| var myevent = { | |
| stop: function(e) { | |
| e.preventDefault(); | |
| e.stopPropagation(); | |
| } | |
| }; | |
| // Handling browser differences (you don't want to do this all over your application, so put it in one facade | |
| var myevent = { | |
| stop: function(e) { | |
| if (typeof e.preventDefault === "function") { | |
| e.preventDefault(); | |
| } | |
| if (typeof e.stopPropagation === "function") { | |
| e.stopPropagation(); | |
| } | |
| // IE | |
| if (typeof e.returnValue === "boolean") { | |
| e.returnValue = false; | |
| } | |
| if (typeof e.cancalBubble === "boolean") { | |
| e.cancalBubble = true; | |
| } | |
| } | |
| }; | |
| // Facade: Hiding commonly-grouped functionality beind one method to prevent code duplication |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment