From b8fef4e23e546ea68d82d42e98b883cf4924f83f Mon Sep 17 00:00:00 2001 From: Peter Donald Date: Wed, 22 May 2019 09:18:40 +1000 Subject: [PATCH] Move standardized document methods to w3c_dom1.js and remove useless overrides of same methods by HTMLDocument The open(...), close(), write(...) and writeln(...) methods on Document are now part of the standard and have been moved to w3c_dom1.js to reflect this. The typing of Document.prototype.open and Document.prototype.close was previously incomplete. These have been aligned with the specification and with the methods in HTMLDocument that overrode these methods. This may impact type checking but that would be very surprising. The overrides in HTMLDocument have been removed. This is done due to limitations of the jsinterop-generator tool that is more fully described in google/jsinterop-generator#35 While the specifications explicitly indicate that these overrides are present and annotates (requiring the [OverrideBuiltins] attribute be applied to the containing interface in WebIDL) it is not expected that this has any practical impact on programs type checking against the externs. --- externs/browser/gecko_dom.js | 24 ------------------------ externs/browser/w3c_dom1.js | 28 ++++++++++++++++++++++++++++ externs/browser/w3c_dom2.js | 34 ---------------------------------- 3 files changed, 28 insertions(+), 58 deletions(-) diff --git a/externs/browser/gecko_dom.js b/externs/browser/gecko_dom.js index eacb1bb58bb..9eb9aea3759 100644 --- a/externs/browser/gecko_dom.js +++ b/externs/browser/gecko_dom.js @@ -301,11 +301,6 @@ Document.prototype.vlinkColor; */ Document.prototype.clear = function() {}; -/** - * @see https://developer.mozilla.org/en/DOM/document.close - */ -Document.prototype.close; - /** * @param {string} type * @return {Event} @@ -340,11 +335,6 @@ Document.prototype.getElementsByClassName = function(name) {}; Document.prototype.load = function(uri) {}; Document.prototype.loadOverlay; -/** - * @see https://developer.mozilla.org/en/DOM/document.open - */ -Document.prototype.open; - /** * @see https://developer.mozilla.org/en/Midas * @see http://msdn.microsoft.com/en-us/library/ms536676(VS.85).aspx @@ -377,20 +367,6 @@ Document.prototype.queryCommandSupported; */ Document.prototype.queryCommandValue; -/** - * @see https://developer.mozilla.org/en/DOM/document.write - * @param {!TrustedHTML|string} text - * @return {undefined} - */ -Document.prototype.write = function(text) {}; - -/** - * @see https://developer.mozilla.org/en/DOM/document.writeln - * @param {!TrustedHTML|string} text - * @return {undefined} - */ -Document.prototype.writeln = function(text) {}; - Document.prototype.ononline; Document.prototype.onoffline; diff --git a/externs/browser/w3c_dom1.js b/externs/browser/w3c_dom1.js index ec9b3fc44b1..3413f15264c 100644 --- a/externs/browser/w3c_dom1.js +++ b/externs/browser/w3c_dom1.js @@ -422,6 +422,34 @@ Document.prototype.createTextNode = function(data) {}; */ Document.prototype.getElementsByTagName = function(tagname) {}; +/** + * @param {string=} opt_unused1 + * @param {string=} opt_unused2 + * @return {undefined} + * @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-document-open + */ +Document.prototype.open = function(opt_unused1, opt_unused2) {}; + +/** + * @return {undefined} + * @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-document-close + */ +Document.prototype.close = function() {}; + +/** + * @param {!TrustedHTML|string} text + * @return {undefined} + * @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-document-write + */ +Document.prototype.write = function(text) {}; + +/** + * @param {!TrustedHTML|string} text + * @return {undefined} + * @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-document-writeln + */ +Document.prototype.writeln = function(text) {}; + /** * @constructor * @implements {IArrayLike} diff --git a/externs/browser/w3c_dom2.js b/externs/browser/w3c_dom2.js index dfe7f856576..e173a63b90f 100644 --- a/externs/browser/w3c_dom2.js +++ b/externs/browser/w3c_dom2.js @@ -239,40 +239,6 @@ HTMLDocument.prototype.anchors; */ HTMLDocument.prototype.cookie; -/** - * @param {string=} opt_mimeType - * @param {string=} opt_replace - * @return {undefined} - * @see http://www.w3.org/TR/2000/CR-DOM-Level-2-20000510/html.html#ID-72161170 - * Even though official spec says "no parameters" some old browsers might take - * optional parameters: https://msdn.microsoft.com/en-us/library/ms536652(v=vs.85).aspx - * @override - */ -HTMLDocument.prototype.open = function(opt_mimeType, opt_replace) {}; - -/** - * @return {undefined} - * @see http://www.w3.org/TR/2000/CR-DOM-Level-2-20000510/html.html#ID-98948567 - * @override - */ -HTMLDocument.prototype.close = function() {}; - -/** - * @param {!TrustedHTML|string} text - * @return {undefined} - * @see http://www.w3.org/TR/2000/CR-DOM-Level-2-20000510/html.html#ID-75233634 - * @override - */ -HTMLDocument.prototype.write = function(text) {}; - -/** - * @param {!TrustedHTML|string} text - * @return {undefined} - * @see http://www.w3.org/TR/2000/CR-DOM-Level-2-20000510/html.html#ID-35318390 - * @override - */ -HTMLDocument.prototype.writeln = function(text) {}; - /** * @param {string} elementName * @return {!NodeList}