diff --git a/closure/goog/dom/safe.js b/closure/goog/dom/safe.js index 02c574ae69..6ea3bdb6c4 100644 --- a/closure/goog/dom/safe.js +++ b/closure/goog/dom/safe.js @@ -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', @@ -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'; @@ -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'; @@ -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'; @@ -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'; @@ -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'; @@ -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'; @@ -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'; @@ -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'; @@ -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'; @@ -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'; @@ -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'; @@ -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'; @@ -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'; @@ -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'; @@ -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'; @@ -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'; @@ -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) { @@ -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'; @@ -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'; @@ -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'; @@ -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'; @@ -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'; @@ -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'; @@ -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'; @@ -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); @@ -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_(