|
@@ -16,6 +16,13 @@ const getNextId = function () {
|
|
|
return ++nextId
|
|
|
}
|
|
|
|
|
|
+// A list of removed attributes from 3.0.
|
|
|
+const removedAttributes = [
|
|
|
+ 'autoresize',
|
|
|
+ 'disableguestresize',
|
|
|
+ 'guestinstance'
|
|
|
+]
|
|
|
+
|
|
|
// Represents the internal state of the WebView node.
|
|
|
class WebViewImpl {
|
|
|
constructor (webviewNode) {
|
|
@@ -24,8 +31,16 @@ class WebViewImpl {
|
|
|
this.elementAttached = false
|
|
|
this.beforeFirstNavigation = true
|
|
|
|
|
|
+ // Check for removed attributes.
|
|
|
+ for (const attributeName of removedAttributes) {
|
|
|
+ if (this.webviewNode.hasAttribute(attributeName)) {
|
|
|
+ this.reportRemovedAttribute(attributeName)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
// on* Event handlers.
|
|
|
this.on = {}
|
|
|
+
|
|
|
this.internalElement = this.createInternalElement()
|
|
|
const shadowRoot = this.webviewNode.attachShadow({mode: 'open'})
|
|
|
shadowRoot.innerHTML = '<!DOCTYPE html><style type="text/css">:host { display: flex; }</style>'
|
|
@@ -102,6 +117,11 @@ class WebViewImpl {
|
|
|
// attribute, if necessary. See BrowserPlugin::UpdateDOMAttribute for more
|
|
|
// details.
|
|
|
handleWebviewAttributeMutation (attributeName, oldValue, newValue) {
|
|
|
+ if (removedAttributes.includes(attributeName)) {
|
|
|
+ this.reportRemovedAttribute(attributeName)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
if (!this.attributes[attributeName] || this.attributes[attributeName].ignoreMutation) {
|
|
|
return
|
|
|
}
|
|
@@ -197,6 +217,12 @@ class WebViewImpl {
|
|
|
// even documented.
|
|
|
this.resizeObserver = new ResizeObserver(this.onElementResize.bind(this)).observe(this.internalElement)
|
|
|
}
|
|
|
+
|
|
|
+ // TODO(zcbenz): Remove the warning in 4.0.
|
|
|
+ reportRemovedAttribute (attributeName) {
|
|
|
+ console.error(`The "${attributeName}" attribute has been removed from the <webview> tag,`,
|
|
|
+ 'see https://github.com/electron/electron/issues/14120 for more.')
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// Registers <webview> custom element.
|