Skip to content
This repository has been archived by the owner on Jul 9, 2022. It is now read-only.

Commit

Permalink
Move standardized document methods to w3c_dom1.js and remove useless …
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
realityforge committed May 21, 2019
1 parent bd445e7 commit b8fef4e
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 58 deletions.
24 changes: 0 additions & 24 deletions externs/browser/gecko_dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;

Expand Down
28 changes: 28 additions & 0 deletions externs/browser/w3c_dom1.js
Original file line number Diff line number Diff line change
Expand Up @@ -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<T>}
Expand Down
34 changes: 0 additions & 34 deletions externs/browser/w3c_dom2.js
Original file line number Diff line number Diff line change
Expand Up @@ -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<!Element>}
Expand Down

0 comments on commit b8fef4e

Please sign in to comment.