Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: third_party/polymer/v1_0/components-chromium/iron-location/iron-location-extracted.js

Issue 1984963002: Roll Polymer elements (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 'use strict'; 1 'use strict';
2 2
3 Polymer({ 3 Polymer({
4 is: 'iron-location', 4 is: 'iron-location',
5 properties: { 5 properties: {
6 /** 6 /**
7 * The pathname component of the URL. 7 * The pathname component of the URL.
8 */ 8 */
9 path: { 9 path: {
10 type: String, 10 type: String,
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 } 184 }
185 window.history.pushState({}, '', href); 185 window.history.pushState({}, '', href);
186 this.fire('location-changed', {}, {node: window}); 186 this.fire('location-changed', {}, {node: window});
187 event.preventDefault(); 187 event.preventDefault();
188 }, 188 },
189 /** 189 /**
190 * Returns the absolute URL of the link (if any) that this click event 190 * Returns the absolute URL of the link (if any) that this click event
191 * is clicking on, if we can and should override the resulting full 191 * is clicking on, if we can and should override the resulting full
192 * page navigation. Returns null otherwise. 192 * page navigation. Returns null otherwise.
193 * 193 *
194 * This method is separated away from _globalOnClick for testability,
195 * as we can't test that a clicked link should have resulted in navigating
196 * away from the test page.
197 *
198 * @param {MouseEvent} event . 194 * @param {MouseEvent} event .
199 * @return {string?} . 195 * @return {string?} .
200 */ 196 */
201 _getSameOriginLinkHref: function(event) { 197 _getSameOriginLinkHref: function(event) {
202 // We only care about left-clicks. 198 // We only care about left-clicks.
203 if (event.button !== 0) { 199 if (event.button !== 0) {
204 return null; 200 return null;
205 } 201 }
206 // We don't want modified clicks, where the intent is to open the page 202 // We don't want modified clicks, where the intent is to open the page
207 // in a new tab. 203 // in a new tab.
208 if (event.metaKey || event.ctrlKey) { 204 if (event.metaKey || event.ctrlKey) {
209 return null; 205 return null;
210 } 206 }
211 var eventPath = Polymer.dom(event).path; 207 var eventPath = Polymer.dom(event).path;
212 var href = null; 208 var anchor = null;
213 for (var i = 0; i < eventPath.length; i++) { 209 for (var i = 0; i < eventPath.length; i++) {
214 var element = eventPath[i]; 210 var element = eventPath[i];
215 if (element.tagName === 'A' && element.href) { 211 if (element.tagName === 'A' && element.href) {
216 href = element.href; 212 anchor = element;
217 break; 213 break;
218 } 214 }
219 } 215 }
216
220 // If there's no link there's nothing to do. 217 // If there's no link there's nothing to do.
221 if (!href) { 218 if (!anchor) {
222 return null; 219 return;
223 } 220 }
224 221
222 // Target blank is a new tab, don't intercept.
223 if (anchor.target === '_blank') {
224 return;
225 }
226 // If the link is for an existing parent frame, don't intercept.
227 if ((anchor.target === '_top' ||
228 anchor.target === '_parent') &&
229 window.top !== window) {
230 return;
231 }
232
233 var href = anchor.href;
234
225 // It only makes sense for us to intercept same-origin navigations. 235 // It only makes sense for us to intercept same-origin navigations.
226 // pushState/replaceState don't work with cross-origin links. 236 // pushState/replaceState don't work with cross-origin links.
227 var url; 237 var url;
228 if (document.baseURI != null) { 238 if (document.baseURI != null) {
229 url = new URL(href, /** @type {string} */(document.baseURI)); 239 url = new URL(href, /** @type {string} */(document.baseURI));
230 } else { 240 } else {
231 url = new URL(href); 241 url = new URL(href);
232 } 242 }
233 243
234 var origin; 244 var origin;
(...skipping 21 matching lines...) Expand all
256 } 266 }
257 // Need to use a full URL in case the containing page has a base URI. 267 // Need to use a full URL in case the containing page has a base URI.
258 var fullNormalizedHref = new URL( 268 var fullNormalizedHref = new URL(
259 normalizedHref, window.location.href).href; 269 normalizedHref, window.location.href).href;
260 return fullNormalizedHref; 270 return fullNormalizedHref;
261 }, 271 },
262 _makeRegExp: function(urlSpaceRegex) { 272 _makeRegExp: function(urlSpaceRegex) {
263 return RegExp(urlSpaceRegex); 273 return RegExp(urlSpaceRegex);
264 } 274 }
265 }); 275 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698