Fix relative links in "src" of <webview>
This commit is contained in:
parent
1cdbb6f186
commit
6624fd9a1b
1 changed files with 12 additions and 3 deletions
|
@ -3,6 +3,12 @@ guestViewInternal = require './guest-view-internal'
|
||||||
webViewConstants = require './web-view-constants'
|
webViewConstants = require './web-view-constants'
|
||||||
remote = require 'remote'
|
remote = require 'remote'
|
||||||
|
|
||||||
|
# Helper function to resolve url set in attribute.
|
||||||
|
a = document.createElement 'a'
|
||||||
|
resolveUrl = (url) ->
|
||||||
|
a.href = url
|
||||||
|
a.href
|
||||||
|
|
||||||
# Attribute objects.
|
# Attribute objects.
|
||||||
# Default implementation of a WebView attribute.
|
# Default implementation of a WebView attribute.
|
||||||
class WebViewAttribute
|
class WebViewAttribute
|
||||||
|
@ -107,6 +113,12 @@ class SrcAttribute extends WebViewAttribute
|
||||||
super webViewConstants.ATTRIBUTE_SRC, webViewImpl
|
super webViewConstants.ATTRIBUTE_SRC, webViewImpl
|
||||||
@setupMutationObserver()
|
@setupMutationObserver()
|
||||||
|
|
||||||
|
getValue: ->
|
||||||
|
if @webViewImpl.webviewNode.hasAttribute @name
|
||||||
|
resolveUrl @webViewImpl.webviewNode.getAttribute(@name)
|
||||||
|
else
|
||||||
|
''
|
||||||
|
|
||||||
handleMutation: (oldValue, newValue) ->
|
handleMutation: (oldValue, newValue) ->
|
||||||
# Once we have navigated, we don't allow clearing the src attribute.
|
# Once we have navigated, we don't allow clearing the src attribute.
|
||||||
# Once <webview> enters a navigated state, it cannot return to a
|
# Once <webview> enters a navigated state, it cannot return to a
|
||||||
|
@ -158,9 +170,6 @@ class HttpReferrerAttribute extends WebViewAttribute
|
||||||
constructor: (webViewImpl) ->
|
constructor: (webViewImpl) ->
|
||||||
super webViewConstants.ATTRIBUTE_HTTPREFERRER, webViewImpl
|
super webViewConstants.ATTRIBUTE_HTTPREFERRER, webViewImpl
|
||||||
|
|
||||||
handleMutation: (oldValue, newValue) ->
|
|
||||||
SrcAttribute::parse.call this
|
|
||||||
|
|
||||||
# Sets up all of the webview attributes.
|
# Sets up all of the webview attributes.
|
||||||
WebViewImpl::setupWebViewAttributes = ->
|
WebViewImpl::setupWebViewAttributes = ->
|
||||||
@attributes = {}
|
@attributes = {}
|
||||||
|
|
Loading…
Reference in a new issue