Skip to content
This repository has been archived by the owner on Aug 1, 2024. It is now read-only.

Commit

Permalink
Delete deprecated methods in goog.dom.asserts, as they are superceeed…
Browse files Browse the repository at this point in the history
…ed by equivalent methods in goog.asserts.dom.

RELNOTES: Delete deprecated methods in goog.dom.asserts, as they are superceeeded by equivalent methods in goog.asserts.dom.
PiperOrigin-RevId: 494048708
Change-Id: I81222281f10746167fa1bd2ae33749d7070e3c28
  • Loading branch information
12wrigja authored and copybara-github committed Dec 9, 2022
1 parent df436e8 commit dbdb5a2
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 521 deletions.
281 changes: 0 additions & 281 deletions closure/goog/dom/asserts.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,287 +68,6 @@ goog.dom.asserts.assertIsLocation = function(o) {
};


/**
* Asserts that a given object is either the given subtype of Element
* or a non-Element, non-Location Mock.
*
* To permit this assertion to pass in the context of tests where DOM
* APIs might be mocked, also accepts any other type except for
* subtypes of {!Element}. This is to ensure that, for instance,
* HTMLScriptElement is not being used in place of a HTMLImageElement,
* since this could result in security bugs due to stronger contracts
* required for assignments to the src property of the latter.
*
* The DOM type is looked up in the window the object belongs to. In
* some contexts, this might not be possible (e.g. when running tests
* outside a browser, cross-domain lookup). In this case, the
* assertions are skipped.
*
* @param {?Object} o The object whose type to assert.
* @param {string} typename The name of the DOM type.
* @return {!Element} The object.
* @private
*/
// TODO(bangert): Make an analog of goog.dom.TagName to correctly handle casts?
goog.dom.asserts.assertIsElementType_ = function(o, typename) {
'use strict';
if (goog.asserts.ENABLE_ASSERTS) {
var win = goog.dom.asserts.getWindow_(o);
if (win && typeof win[typename] != 'undefined') {
if (!o ||
(!(o instanceof win[typename]) &&
(o instanceof win.Location || o instanceof win.Element))) {
goog.asserts.fail(
'Argument is not a %s (or a non-Element, non-Location mock); ' +
'got: %s',
typename, goog.dom.asserts.debugStringForType_(o));
}
}
}
return /** @type {!Element} */ (o);
};

/**
* Asserts that a given object is a HTMLAnchorElement.
*
* To permit this assertion to pass in the context of tests where elements might
* be mocked, also accepts objects that are not of type Location nor a subtype
* of Element.
*
* @param {?Object} o The object whose type to assert.
* @return {!HTMLAnchorElement}
* @deprecated Use goog.asserts.dom.assertIsHtmlAnchorElement instead.
*/
goog.dom.asserts.assertIsHTMLAnchorElement = function(o) {
'use strict';
return /** @type {!HTMLAnchorElement} */ (
goog.dom.asserts.assertIsElementType_(o, 'HTMLAnchorElement'));
};

/**
* Asserts that a given object is a HTMLButtonElement.
*
* To permit this assertion to pass in the context of tests where elements might
* be mocked, also accepts objects that are not a subtype of Element.
*
* @param {?Object} o The object whose type to assert.
* @return {!HTMLButtonElement}
* @deprecated Use goog.asserts.dom.assertIsHtmlButtonElement instead.
*/
goog.dom.asserts.assertIsHTMLButtonElement = function(o) {
'use strict';
return /** @type {!HTMLButtonElement} */ (
goog.dom.asserts.assertIsElementType_(o, 'HTMLButtonElement'));
};

/**
* Asserts that a given object is a HTMLLinkElement.
*
* To permit this assertion to pass in the context of tests where elements might
* be mocked, also accepts objects that are not a subtype of Element.
*
* @param {?Object} o The object whose type to assert.
* @return {!HTMLLinkElement}
* @deprecated Use goog.asserts.dom.assertIsHtmlLinkElement instead.
*/
goog.dom.asserts.assertIsHTMLLinkElement = function(o) {
'use strict';
return /** @type {!HTMLLinkElement} */ (
goog.dom.asserts.assertIsElementType_(o, 'HTMLLinkElement'));
};

/**
* Asserts that a given object is a HTMLImageElement.
*
* To permit this assertion to pass in the context of tests where elements might
* be mocked, also accepts objects that are not a subtype of Element.
*
* @param {?Object} o The object whose type to assert.
* @return {!HTMLImageElement}
* @deprecated Use goog.asserts.dom.assertIsHtmlImageElement instead.
*/
goog.dom.asserts.assertIsHTMLImageElement = function(o) {
'use strict';
return /** @type {!HTMLImageElement} */ (
goog.dom.asserts.assertIsElementType_(o, 'HTMLImageElement'));
};

/**
* Asserts that a given object is a HTMLAudioElement.
*
* To permit this assertion to pass in the context of tests where elements might
* be mocked, also accepts objects that are not a subtype of Element.
*
* @param {?Object} o The object whose type to assert.
* @return {!HTMLAudioElement}
* @deprecated Use goog.asserts.dom.assertIsHtmlAudioElement instead.
*/
goog.dom.asserts.assertIsHTMLAudioElement = function(o) {
'use strict';
return /** @type {!HTMLAudioElement} */ (
goog.dom.asserts.assertIsElementType_(o, 'HTMLAudioElement'));
};

/**
* Asserts that a given object is a HTMLVideoElement.
*
* To permit this assertion to pass in the context of tests where elements might
* be mocked, also accepts objects that are not a subtype of Element.
*
* @param {?Object} o The object whose type to assert.
* @return {!HTMLVideoElement}
* @deprecated Use goog.asserts.dom.assertIsHtmlVideoElement instead.
*/
goog.dom.asserts.assertIsHTMLVideoElement = function(o) {
'use strict';
return /** @type {!HTMLVideoElement} */ (
goog.dom.asserts.assertIsElementType_(o, 'HTMLVideoElement'));
};

/**
* Asserts that a given object is a HTMLInputElement.
*
* To permit this assertion to pass in the context of tests where elements might
* be mocked, also accepts objects that are not a subtype of Element.
*
* @param {?Object} o The object whose type to assert.
* @return {!HTMLInputElement}
* @deprecated Use goog.asserts.dom.assertIsHtmlInputElement instead.
*/
goog.dom.asserts.assertIsHTMLInputElement = function(o) {
'use strict';
return /** @type {!HTMLInputElement} */ (
goog.dom.asserts.assertIsElementType_(o, 'HTMLInputElement'));
};

/**
* Asserts that a given object is a HTMLTextAreaElement.
*
* To permit this assertion to pass in the context of tests where elements might
* be mocked, also accepts objects that are not a subtype of Element.
*
* @param {?Object} o The object whose type to assert.
* @return {!HTMLTextAreaElement}
* @deprecated Use goog.asserts.dom.assertIsHtmlTextAreaElement instead.
*/
goog.dom.asserts.assertIsHTMLTextAreaElement = function(o) {
'use strict';
return /** @type {!HTMLTextAreaElement} */ (
goog.dom.asserts.assertIsElementType_(o, 'HTMLTextAreaElement'));
};

/**
* Asserts that a given object is a HTMLCanvasElement.
*
* To permit this assertion to pass in the context of tests where elements might
* be mocked, also accepts objects that are not a subtype of Element.
*
* @param {?Object} o The object whose type to assert.
* @return {!HTMLCanvasElement}
* @deprecated Use goog.asserts.dom.assertIsHtmlCanvasElement instead.
*/
goog.dom.asserts.assertIsHTMLCanvasElement = function(o) {
'use strict';
return /** @type {!HTMLCanvasElement} */ (
goog.dom.asserts.assertIsElementType_(o, 'HTMLCanvasElement'));
};

/**
* Asserts that a given object is a HTMLEmbedElement.
*
* To permit this assertion to pass in the context of tests where elements might
* be mocked, also accepts objects that are not a subtype of Element.
*
* @param {?Object} o The object whose type to assert.
* @return {!HTMLEmbedElement}
* @deprecated Use goog.asserts.dom.assertIsHtmlEmbedElement instead.
*/
goog.dom.asserts.assertIsHTMLEmbedElement = function(o) {
'use strict';
return /** @type {!HTMLEmbedElement} */ (
goog.dom.asserts.assertIsElementType_(o, 'HTMLEmbedElement'));
};

/**
* Asserts that a given object is a HTMLFormElement.
*
* To permit this assertion to pass in the context of tests where elements might
* be mocked, also accepts objects that are not a subtype of Element.
*
* @param {?Object} o The object whose type to assert.
* @return {!HTMLFormElement}
* @deprecated Use goog.asserts.dom.assertIsHtmlFormElement instead.
*/
goog.dom.asserts.assertIsHTMLFormElement = function(o) {
'use strict';
return /** @type {!HTMLFormElement} */ (
goog.dom.asserts.assertIsElementType_(o, 'HTMLFormElement'));
};

/**
* Asserts that a given object is a HTMLFrameElement.
*
* To permit this assertion to pass in the context of tests where elements might
* be mocked, also accepts objects that are not a subtype of Element.
*
* @param {?Object} o The object whose type to assert.
* @return {!HTMLFrameElement}
* @deprecated Use goog.asserts.dom.assertIsHtmlFrameElement instead.
*/
goog.dom.asserts.assertIsHTMLFrameElement = function(o) {
'use strict';
return /** @type {!HTMLFrameElement} */ (
goog.dom.asserts.assertIsElementType_(o, 'HTMLFrameElement'));
};

/**
* Asserts that a given object is a HTMLIFrameElement.
*
* To permit this assertion to pass in the context of tests where elements might
* be mocked, also accepts objects that are not a subtype of Element.
*
* @param {?Object} o The object whose type to assert.
* @return {!HTMLIFrameElement}
* @deprecated Use goog.asserts.dom.assertIsHtmlIFrameElement instead.
*/
goog.dom.asserts.assertIsHTMLIFrameElement = function(o) {
'use strict';
return /** @type {!HTMLIFrameElement} */ (
goog.dom.asserts.assertIsElementType_(o, 'HTMLIFrameElement'));
};

/**
* Asserts that a given object is a HTMLObjectElement.
*
* To permit this assertion to pass in the context of tests where elements might
* be mocked, also accepts objects that are not a subtype of Element.
*
* @param {?Object} o The object whose type to assert.
* @return {!HTMLObjectElement}
* @deprecated Use goog.asserts.dom.assertIsHtmlObjectElement instead.
*/
goog.dom.asserts.assertIsHTMLObjectElement = function(o) {
'use strict';
return /** @type {!HTMLObjectElement} */ (
goog.dom.asserts.assertIsElementType_(o, 'HTMLObjectElement'));
};

/**
* Asserts that a given object is a HTMLScriptElement.
*
* To permit this assertion to pass in the context of tests where elements might
* be mocked, also accepts objects that are not a subtype of Element.
*
* @param {?Object} o The object whose type to assert.
* @return {!HTMLScriptElement}
* @deprecated Use goog.asserts.dom.assertIsHtmlScriptElement instead.
*/
goog.dom.asserts.assertIsHTMLScriptElement = function(o) {
'use strict';
return /** @type {!HTMLScriptElement} */ (
goog.dom.asserts.assertIsElementType_(o, 'HTMLScriptElement'));
};

/**
* Returns a string representation of a value's type.
*
Expand Down
Loading

0 comments on commit dbdb5a2

Please sign in to comment.