Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: html/static/js/ieEventListenerPolyfill.js

Issue 6196733759455232: Issue 1181 - Change polyfill for IE8 (fix settings page) (Closed)
Left Patch Set: Add back addEventListener/removeEventListener handlers Created Aug. 8, 2014, 1:30 p.m.
Right Patch Set: Reuse code for addEventListener/removeEventListener Created Aug. 8, 2014, 2:18 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « html/static/js/firstRun.js ('k') | html/static/js/ieFirstRun.js » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 if (typeof window.addEventListener != "function") 1 if (typeof window.addEventListener != "function")
2 { 2 {
3 window.addEventListener = function(type, handler, capture) 3 window.addEventListener = function(type, handler, capture)
4 { 4 {
5 this.attachEvent("on" + type, handler) 5 this.attachEvent("on" + type, handler)
6 }; 6 };
7 } 7 }
8 8
9 if (typeof window.removeEventListener != "function") 9 if (typeof window.removeEventListener != "function")
10 { 10 {
11 window.removeEventListener = function(type, handler) 11 window.removeEventListener = function(type, handler)
12 { 12 {
13 this.detachEvent("on" + type, handler) 13 this.detachEvent("on" + type, handler)
14 }; 14 };
15 } 15 }
16 16
17 if (typeof Element.prototype.addEventListener != "function") 17 if (typeof Element.prototype.addEventListener != "function")
Felix Dahlke 2014/08/08 13:58:35 My question remains: Is this still necessary to fi
Oleksandr 2014/08/08 14:05:17 Oh, I miss understood you before then. Yes, it is
Felix Dahlke 2014/08/08 14:07:01 Ah, I see! Misunderstanding then.
18 { 18 {
19 Element.prototype.addEventListener = function(type, handler, capture) 19 Element.prototype.addEventListener = window.addEventListener;
Felix Dahlke 2014/08/08 14:07:01 Can we assign this to window.addEventListener, and
Oleksandr 2014/08/08 14:19:34 Looks like we've tried every combination now :)
Felix Dahlke 2014/08/08 14:21:12 Yes, I like this one best :)
20 {
21 this.attachEvent("on" + type, handler)
22 };
23 } 20 }
24 21
25 if (typeof Element.prototype.removeEventListener != "function") 22 if (typeof Element.prototype.removeEventListener != "function")
26 { 23 {
27 Element.prototype.removeEventListener = function(type, handler) 24 Element.prototype.removeEventListener = window.removeEventListener;
28 {
29 this.detachEvent("on" + type, handler)
30 };
31 } 25 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld