Left: | ||
Right: |
OLD | NEW |
---|---|
(Empty) | |
1 /* | |
2 * This file is part of Adblock Plus <https://adblockplus.org/>, | |
3 * Copyright (C) 2006-2015 Eyeo GmbH | |
4 * | |
5 * Adblock Plus is free software: you can redistribute it and/or modify | |
6 * it under the terms of the GNU General Public License version 3 as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * Adblock Plus is distributed in the hope that it will be useful, | |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 * GNU General Public License for more details. | |
13 * | |
14 * You should have received a copy of the GNU General Public License | |
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | |
16 */ | |
17 | |
18 "use strict"; | |
kzar
2016/01/16 16:05:28
Again shouldn't this be inside the IIFE?
Sebastian Noack
2016/01/19 14:13:21
Again, it shouldn't. ;)
Putting "use strict" on t
kzar
2016/01/19 15:24:02
Acknowledged.
| |
19 | |
20 (function(global) | |
21 { | |
22 // Chrome <35 and Safari 6 used the non-standard name webkitURL | |
23 if (!("URL" in global) && "webkitURL" in global) | |
24 global.URL = global.webkitURL; | |
25 | |
26 // Chrome <32 didn't implement any of those properties | |
kzar
2016/01/16 16:05:28
Couldn't we avoid checking these properties exist
Sebastian Noack
2016/01/19 14:13:21
Note that Safari 6 and Chrome 32-34 uses the non-s
kzar
2016/01/19 15:24:02
Yea I understand that, just suggesting changing th
Sebastian Noack
2016/01/19 16:03:39
That seems to be true. But skipping that check if
kzar
2016/01/19 16:12:07
Acknowledged.
| |
27 var URLProperties = ["href", "protocol", "host", "hostname", "pathname", "sear ch"]; | |
kzar
2016/01/16 16:05:28
Nit: this line is too long
Sebastian Noack
2016/01/19 14:13:21
Done.
| |
28 if ("URL" in global) | |
29 { | |
30 var dummy = new URL("about:blank"); | |
31 if (URLProperties.every(function(prop) { return prop in dummy; })) | |
32 return; | |
33 } | |
34 | |
35 var doc = document.implementation.createHTMLDocument(); | |
36 var base = doc.createElement("base"); | |
37 doc.head.appendChild(base); | |
38 var anchor = doc.createElement("a"); | |
39 doc.body.appendChild(anchor); | |
40 | |
41 global.URL = function(url, baseUrl) | |
kzar
2016/01/16 16:05:28
A few things that I noticed behave differently wit
Sebastian Noack
2016/01/19 14:13:21
As for the other two polyfills, it's not the objec
kzar
2016/01/19 15:24:02
I think with the missing properties, especially ha
Sebastian Noack
2016/01/19 16:03:39
The way URL objects are currently used in Adblock
kzar
2016/01/19 16:12:07
Acknowledged.
| |
42 { | |
43 if (baseUrl instanceof URL) | |
kzar
2016/01/16 16:05:28
should be `... instanceof global.URL)`?
Sebastian Noack
2016/01/19 14:13:21
As in the other review, that isn't necessary, but
kzar
2016/01/19 15:24:02
Acknowledged.
| |
44 base.href = baseUrl.href; | |
45 else | |
46 base.href = baseUrl || ""; | |
47 anchor.href = url; | |
48 | |
49 for (var i = 0; i < URLProperties.length; i++) | |
50 { | |
51 var prop = URLProperties[i]; | |
52 this[prop] = anchor[prop]; | |
53 } | |
54 }; | |
55 })(this); | |
OLD | NEW |