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

Commit

Permalink
Updates the deprecation warnings on dom.safe
Browse files Browse the repository at this point in the history
RELNOTES: Updates the deprecation warnings on dom.safe.

PiperOrigin-RevId: 574809450
Change-Id: Ie3c7bfd8fcba43b414b30a5777e46ae4ee37f71e
  • Loading branch information
Closure Team authored and copybara-github committed Oct 19, 2023
1 parent 7a06212 commit 11b2f3c
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion closure/goog/dom/safe.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ goog.require('goog.string.Const');
goog.require('goog.string.internal');


/** @enum {string} */
/**
* @enum {string}
* @deprecated Use a plain string value instead.
*/
goog.dom.safe.InsertAdjacentHtmlPosition = {
AFTERBEGIN: 'afterbegin',
AFTEREND: 'afterend',
Expand All @@ -61,6 +64,7 @@ goog.dom.safe.InsertAdjacentHtmlPosition = {
* @param {!goog.dom.safe.InsertAdjacentHtmlPosition} position Position where
* to insert the HTML.
* @param {!goog.html.SafeHtml} html The known-safe HTML to insert.
* @deprecated Use a `safevalues.dom.safeElement.insertAdjacentHtml` instead.
*/
goog.dom.safe.insertAdjacentHtml = function(node, position, html) {
'use strict';
Expand Down Expand Up @@ -150,6 +154,7 @@ goog.dom.safe.unsafeSetInnerHtmlDoNotUseOrElse = function(elem, html) {
* @param {!goog.html.SafeHtml} html The known-safe HTML to assign.
* @throws {Error} If called with one of these tags: math, script, style, svg,
* template.
* @deprecated Use `safevalues.dom.safeElement.setInnerHtml` instead.
*/
goog.dom.safe.setInnerHtml = function(elem, html) {
'use strict';
Expand Down Expand Up @@ -188,6 +193,7 @@ goog.dom.safe.setInnerHtmlFromConstant = function(element, constHtml) {
* Assigns known-safe HTML to an element's outerHTML property.
* @param {!Element} elem The element whose outerHTML is to be assigned to.
* @param {!goog.html.SafeHtml} html The known-safe HTML to assign.
* @deprecated Use `safevalues.dom.safeElement.setOuterHtml` instead.
*/
goog.dom.safe.setOuterHtml = function(elem, html) {
'use strict';
Expand All @@ -214,6 +220,7 @@ goog.dom.safe.setOuterHtml = function(elem, html) {
* @param {string|!goog.html.SafeUrl} url The URL to assign.
* @return {void}
* @see goog.html.SafeUrl#sanitize
* @deprecated Use `safevalues.dom.safeFormEl.setAction` instead.
*/
goog.dom.safe.setFormElementAction = function(form, url) {
'use strict';
Expand Down Expand Up @@ -247,6 +254,7 @@ goog.dom.safe.setFormElementAction = function(form, url) {
* @param {string|!goog.html.SafeUrl} url The URL to assign.
* @return {void}
* @see goog.html.SafeUrl#sanitize
* @deprecated Use `safevalues.dom.safeButtonEl.setFormaction` instead.
*/
goog.dom.safe.setButtonFormAction = function(button, url) {
'use strict';
Expand Down Expand Up @@ -279,6 +287,7 @@ goog.dom.safe.setButtonFormAction = function(button, url) {
* @param {string|!goog.html.SafeUrl} url The URL to assign.
* @return {void}
* @see goog.html.SafeUrl#sanitize
* @deprecated Use `safevalues.dom.safeInputEl.setFormaction` instead.
*/
goog.dom.safe.setInputFormAction = function(input, url) {
'use strict';
Expand Down Expand Up @@ -311,6 +320,7 @@ goog.dom.safe.setStyle = function(elem, style) {
* @param {!Document} doc The document to be written to.
* @param {!goog.html.SafeHtml} html The known-safe HTML to assign.
* @return {void}
* @deprecated Use `safevalues.dom.safeDocument.write` instead.
*/
goog.dom.safe.documentWrite = function(doc, html) {
'use strict';
Expand All @@ -337,6 +347,7 @@ goog.dom.safe.documentWrite = function(doc, html) {
* @param {string|!goog.html.SafeUrl} url The URL to assign.
* @return {void}
* @see goog.html.SafeUrl#sanitize
* @deprecated Use `safevalues.dom.safeAnchorEl.setHref` instead.
*/
goog.dom.safe.setAnchorHref = function(anchor, url) {
'use strict';
Expand Down Expand Up @@ -364,6 +375,7 @@ goog.dom.safe.setAnchorHref = function(anchor, url) {
* @param {string|!goog.html.SafeUrl} url The URL to assign.
* @return {void}
* @see goog.html.SafeUrl#sanitize
* @deprecated Use a plain property assignement `myAudioEl.src = x` instead.
*/
goog.dom.safe.setAudioSrc = function(audioElement, url) {
'use strict';
Expand All @@ -390,6 +402,7 @@ goog.dom.safe.setAudioSrc = function(audioElement, url) {
* @param {string|!goog.html.SafeUrl} url The URL to assign.
* @return {void}
* @see goog.html.SafeUrl#sanitize
* @deprecated Use a plain property assignement `myAudioEl.src = x` instead.
*/
goog.dom.safe.setVideoSrc = function(videoElement, url) {
'use strict';
Expand Down Expand Up @@ -417,6 +430,7 @@ goog.dom.safe.setVideoSrc = function(videoElement, url) {
* @param {!HTMLEmbedElement} embed The embed element whose src property
* is to be assigned to.
* @param {!goog.html.TrustedResourceUrl} url The URL to assign.
* @deprecated Use `safevalues.dom.safeEmbedEl.setSrc` instead.
*/
goog.dom.safe.setEmbedSrc = function(embed, url) {
'use strict';
Expand Down Expand Up @@ -461,6 +475,7 @@ goog.dom.safe.setFrameSrc = function(frame, url) {
* is to be assigned to.
* @param {!goog.html.TrustedResourceUrl} url The URL to assign.
* @return {void}
* @deprecated Use `safevalues.dom.safeIframeEl.setSrc` instead.
*/
goog.dom.safe.setIframeSrc = function(iframe, url) {
'use strict';
Expand All @@ -482,6 +497,7 @@ goog.dom.safe.setIframeSrc = function(iframe, url) {
* is to be assigned to.
* @param {!goog.html.SafeHtml} html The HTML to assign.
* @return {void}
* @deprecated Use `safevalues.dom.safeIframeEl.setSrcdoc` instead.
*/
goog.dom.safe.setIframeSrcdoc = function(iframe, html) {
'use strict';
Expand Down Expand Up @@ -515,6 +531,7 @@ goog.dom.safe.setIframeSrcdoc = function(iframe, html) {
* @throws {Error} if rel contains "stylesheet" and url is not a
* TrustedResourceUrl
* @see goog.html.SafeUrl#sanitize
* @deprecated Use `safevalues.dom.safeLinkEl.setHrefAndRel` instead.
*/
goog.dom.safe.setLinkHrefAndRel = function(link, url, rel) {
'use strict';
Expand Down Expand Up @@ -579,6 +596,7 @@ goog.dom.safe.setObjectData = function(object, url) {
* is to be assigned to.
* @param {!goog.html.TrustedResourceUrl} url The URL to assign.
* @return {void}
* @deprecated Use `safevalues.dom.safeScriptEl.setSrc` instead.
*/
goog.dom.safe.setScriptSrc = function(script, url) {
'use strict';
Expand All @@ -602,6 +620,7 @@ goog.dom.safe.setScriptSrc = function(script, url) {
* set.
* @param {!goog.html.SafeScript} content The content to assign.
* @return {void}
* @deprecated Use `safevalues.dom.safeScriptEl.setTextContent` instead.
*/
goog.dom.safe.setScriptContent = function(script, content) {
'use strict';
Expand Down Expand Up @@ -646,6 +665,7 @@ goog.dom.safe.setNonceForScriptElement_ = function(script) {
* @param {string|!goog.html.SafeUrl} url The URL to assign.
* @return {void}
* @see goog.html.SafeUrl#sanitize
* @deprecated Use `safevalues.dom.safeLocation.setHref` instead.
*/
goog.dom.safe.setLocationHref = function(loc, url) {
Expand Down Expand Up @@ -682,6 +702,7 @@ goog.dom.safe.setLocationHref = function(loc, url) {
* @param {string|!goog.html.SafeUrl} url The URL to assign.
* @return {void}
* @see goog.html.SafeUrl#sanitize
* @deprecated Use `safevalues.dom.safeLocation.assign` instead.
*/
goog.dom.safe.assignLocation = function(loc, url) {
'use strict';
Expand Down Expand Up @@ -715,6 +736,7 @@ goog.dom.safe.assignLocation = function(loc, url) {
* @param {string|!goog.html.SafeUrl} url The URL to assign.
* @return {void}
* @see goog.html.SafeUrl#sanitize
* @deprecated Use `safevalues.dom.safeLocation.replace` instead.
*/
goog.dom.safe.replaceLocation = function(loc, url) {
'use strict';
Expand Down Expand Up @@ -755,6 +777,7 @@ goog.dom.safe.replaceLocation = function(loc, url) {
* @param {string=} opt_specs Comma-separated list of specifications, same as
* in window.open().
* @return {Window} Window the url was opened in.
* @deprecated Use `safevalues.dom.safeWindow.open` instead.
*/
goog.dom.safe.openInWindow = function(url, opt_openerWin, opt_name, opt_specs) {
'use strict';
Expand Down Expand Up @@ -789,6 +812,7 @@ goog.dom.safe.openInWindow = function(url, opt_openerWin, opt_name, opt_specs) {
* @param {!DOMParser} parser
* @param {!goog.html.SafeHtml} html The HTML to be parsed.
* @return {!Document}
* @deprecated Use `safevalues.dom.safeDomParser.parseHtml` instead.
*/
goog.dom.safe.parseFromStringHtml = function(parser, html) {
'use strict';
Expand All @@ -803,6 +827,7 @@ goog.dom.safe.parseFromStringHtml = function(parser, html) {
* XML or SVG supported by this function so we use SafeHtml.
* @param {string} type
* @return {!Document}
* @deprecated Use `safevalues.dom.safeDomParser.parseFromString` instead.
*/
goog.dom.safe.parseFromString = function(parser, content, type) {
'use strict';
Expand All @@ -823,6 +848,8 @@ goog.dom.safe.parseFromString = function(parser, content, type) {
* @param {!Blob} blob The blob to create the image from.
* @return {!HTMLImageElement} The image element created from the blob.
* @throws {!Error} If called with a Blob with a MIME type other than image/.*.
* @deprecated Use `safevalues.objectUrlFromSafeSource` and assign it to the
* img.src.
*/
goog.dom.safe.createImageFromBlob = function(blob) {
'use strict';
Expand All @@ -847,6 +874,7 @@ goog.dom.safe.createImageFromBlob = function(blob) {
* create a fragment in.
* @param {!goog.html.SafeHtml} html HTML to create a fragment from.
* @return {?DocumentFragment}
* @deprecated Use `safevalues.dom.safeRange.createContextualFragment` instead.
*/
goog.dom.safe.createContextualFragment = function(range, html) {
'use strict';
Expand All @@ -859,6 +887,9 @@ goog.dom.safe.createContextualFragment = function(range, html) {
* @param {?Window=} opt_window The window context used to retrieve the nonce.
* Defaults to global context.
* @return {string} CSP nonce or empty string if no nonce is present.
* @deprecated Use `safevalues.dom.safeScriptEl.setSrc` or
* `safevalues.dom.safeScriptEl.setTextContent` which automatically set the
* script nonce.
*/
goog.dom.safe.getScriptNonce = function(opt_window) {
return goog.dom.safe.getNonce_('script[nonce]', opt_window);
Expand All @@ -870,6 +901,7 @@ goog.dom.safe.getScriptNonce = function(opt_window) {
* @param {?Window=} opt_window The window context used to retrieve the nonce.
* Defaults to global context.
* @return {string} CSP nonce or empty string if no nonce is present.
* @deprecated
*/
goog.dom.safe.getStyleNonce = function(opt_window) {
return goog.dom.safe.getNonce_(
Expand Down

0 comments on commit 11b2f3c

Please sign in to comment.