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

Side by Side Diff: lib/polyfill/url.js

Issue 29333522: Issue 3515 - Adapted polyfill for URL class for consistency (Closed)
Patch Set: Created Jan. 14, 2016, 5:22 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | lib/url.js » ('j') | safari/ext/background.js » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 function(global)
19 {
20 // Chrome <35 and Safari 6 used the non-standard name webkitURL
21 if (!("URL" in global) && "webkitURL" in global)
22 global.URL = global.webkitURL;
23
24 // Chrome <32 didn't implement any of those properties
25 var URLProperties = ["href", "protocol", "host", "hostname", "pathname", "sear ch"];
26 if ("URL" in global)
27 {
28 var dummy = new URL("about:blank");
29 if (URLProperties.every(function(prop) { return prop in dummy; }))
30 return;
31 }
32
33 var doc = document.implementation.createHTMLDocument();
34 var base = doc.createElement("base");
35 doc.head.appendChild(base);
36 var anchor = doc.createElement("a");
37 doc.body.appendChild(anchor);
38
39 global.URL = function(url, baseUrl)
40 {
41 if (baseUrl instanceof URL)
42 base.href = baseUrl.href;
43 else
44 base.href = baseUrl || "";
45 anchor.href = url;
46
47 for (var i = 0; i < URLProperties.length; i++)
48 {
49 var prop = URLProperties[i];
50 this[prop] = anchor[prop];
51 }
52 };
53 }(this);
OLDNEW
« no previous file with comments | « no previous file | lib/url.js » ('j') | safari/ext/background.js » ('J')

Powered by Google App Engine
This is Rietveld