goog.labs.html.attribute_rewriter.js Maven / Gradle / Ivy
// Copyright 2014 The Closure Library Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS-IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
goog.provide('goog.labs.html.AttributeRewriter');
goog.provide('goog.labs.html.AttributeValue');
goog.provide('goog.labs.html.attributeRewriterPresubmitWorkaround');
/**
* The type of an attribute value.
*
* Many HTML attributes contain structured data like URLs, CSS, or even entire
* HTML documents, so the type is a union of several variants.
*
* @typedef {(string |
* goog.html.SafeHtml | goog.html.SafeStyle | goog.html.SafeUrl)}
*/
goog.labs.html.AttributeValue;
/**
* A function that takes an attribute value, and returns a safe value.
*
* Since rewriters can be chained, a rewriter must be able to accept the output
* of another rewriter, instead of just a string though a rewriter that coerces
* its input to a string before checking its safety will fail safe.
*
* The meaning of the result is:
*
* {@code null}
* Unsafe. The attribute should not be output.
* a string
* The plain text (not HTML-entity encoded) of a safe attribute
* value.
* a {@link goog.html.SafeHtml}
* A fragment that is safe to be included as embedded HTML as in
* {@code
* a {@link goog.html.SafeUrl}
* A URL that does not need to be further checked against the URL
* white-list.
* a {@link goog.html.SafeStyle}
* A safe value for a style="..."
attribute.
*
*
* Implementations are responsible for making sure that "safe" complies with
* the contract established by the safe string types in {@link goog.html}.
*
*
* @typedef {function(goog.labs.html.AttributeValue) :
* goog.labs.html.AttributeValue}
*/
goog.labs.html.AttributeRewriter;
/**
* g4 presubmit complains about requires of this file because its clients
* don't use any symbols from it outside JSCompiler comment annotations.
* genjsdeps.sh doesn't generate the right dependency graph unless this
* file is required.
* Clients can mention this noop.
*/
goog.labs.html.attributeRewriterPresubmitWorkaround = function() {};