Update wmts-hidpi, add nicer-api-docs

This commit is contained in:
Andreas Hocevar
2014-05-06 13:02:46 -05:00
parent b3ac1afd00
commit 1e25fc5585
2239 changed files with 3726515 additions and 37010 deletions

View File

@@ -0,0 +1,132 @@
// Copyright 2012 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.
/**
* @fileoverview Soy data primitives.
*
* The goal is to encompass data types used by Soy, especially to mark content
* as known to be "safe".
*
* @author gboyer@google.com (Garrett Boyer)
*/
goog.provide('goog.soy.data');
goog.provide('goog.soy.data.SanitizedContent');
goog.provide('goog.soy.data.SanitizedContentKind');
/**
* A type of textual content.
*
* This is an enum of type Object so that these values are unforgeable.
*
* @enum {!Object}
*/
goog.soy.data.SanitizedContentKind = {
/**
* A snippet of HTML that does not start or end inside a tag, comment, entity,
* or DOCTYPE; and that does not contain any executable code
* (JS, {@code <object>}s, etc.) from a different trust domain.
*/
HTML: goog.DEBUG ? {sanitizedContentKindHtml: true} : {},
/**
* Executable Javascript code or expression, safe for insertion in a
* script-tag or event handler context, known to be free of any
* attacker-controlled scripts. This can either be side-effect-free
* Javascript (such as JSON) or Javascript that entirely under Google's
* control.
*/
JS: goog.DEBUG ? {sanitizedContentJsStrChars: true} : {},
/**
* A sequence of code units that can appear between quotes (either kind) in a
* JS program without causing a parse error, and without causing any side
* effects.
* <p>
* The content should not contain unescaped quotes, newlines, or anything else
* that would cause parsing to fail or to cause a JS parser to finish the
* string its parsing inside the content.
* <p>
* The content must also not end inside an escape sequence ; no partial octal
* escape sequences or odd number of '{@code \}'s at the end.
*/
JS_STR_CHARS: goog.DEBUG ? {sanitizedContentJsStrChars: true} : {},
/** A properly encoded portion of a URI. */
URI: goog.DEBUG ? {sanitizedContentUri: true} : {},
/**
* Repeated attribute names and values. For example,
* {@code dir="ltr" foo="bar" onclick="trustedFunction()" checked}.
*/
ATTRIBUTES: goog.DEBUG ? {sanitizedContentHtmlAttribute: true} : {},
// TODO: Consider separating rules, declarations, and values into
// separate types, but for simplicity, we'll treat explicitly blessed
// SanitizedContent as allowed in all of these contexts.
/**
* A CSS3 declaration, property, value or group of semicolon separated
* declarations.
*/
CSS: goog.DEBUG ? {sanitizedContentCss: true} : {},
/**
* Unsanitized plain-text content.
*
* This is effectively the "null" entry of this enum, and is sometimes used
* to explicitly mark content that should never be used unescaped. Since any
* string is safe to use as text, being of ContentKind.TEXT makes no
* guarantees about its safety in any other context such as HTML.
*/
TEXT: goog.DEBUG ? {sanitizedContentKindText: true} : {}
};
/**
* A string-like object that carries a content-type.
*
* IMPORTANT! Do not create these directly, nor instantiate the subclasses.
* Instead, use a trusted, centrally reviewed library as endorsed by your team
* to generate these objects. Otherwise, you risk accidentally creating
* SanitizedContent that is attacker-controlled and gets evaluated unescaped in
* templates.
*
* @constructor
*/
goog.soy.data.SanitizedContent = function() {
throw Error('Do not instantiate directly');
};
/**
* The context in which this content is safe from XSS attacks.
* @type {goog.soy.data.SanitizedContentKind}
*/
goog.soy.data.SanitizedContent.prototype.contentKind;
/**
* The already-safe content.
* @type {string}
*/
goog.soy.data.SanitizedContent.prototype.content;
/** @override */
goog.soy.data.SanitizedContent.prototype.toString = function() {
return this.content;
};

View File

@@ -0,0 +1,266 @@
// Copyright 2010 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.
/**
* @fileoverview Provides a soy renderer that allows registration of
* injected data ("globals") that will be passed into the rendered
* templates.
*
* There is also an interface {@link goog.soy.InjectedDataSupplier} that
* user should implement to provide the injected data for a specific
* application. The injected data format is a JavaScript object:
* <pre>
* {'dataKey': 'value', 'otherDataKey': 'otherValue'}
* </pre>
*
* To use injected data, you need to enable the soy-to-js compiler
* option {@code --isUsingIjData}. The injected data can then be
* referred to in any soy templates as part of a magic "ij"
* parameter. For example, {@code $ij.dataKey} will evaluate to
* 'value' with the above injected data.
*
* @author henrywong@google.com (Henry Wong)
* @author chrishenry@google.com (Chris Henry)
*/
goog.provide('goog.soy.InjectedDataSupplier');
goog.provide('goog.soy.Renderer');
goog.require('goog.asserts');
goog.require('goog.dom');
goog.require('goog.soy');
goog.require('goog.soy.data.SanitizedContent');
goog.require('goog.soy.data.SanitizedContentKind');
/**
* Creates a new soy renderer. Note that the renderer will only be
* guaranteed to work correctly within the document scope provided in
* the DOM helper.
*
* @param {goog.soy.InjectedDataSupplier=} opt_injectedDataSupplier A supplier
* that provides an injected data.
* @param {goog.dom.DomHelper=} opt_domHelper Optional DOM helper;
* defaults to that provided by {@code goog.dom.getDomHelper()}.
* @constructor
*/
goog.soy.Renderer = function(opt_injectedDataSupplier, opt_domHelper) {
/**
* @type {goog.dom.DomHelper}
* @private
*/
this.dom_ = opt_domHelper || goog.dom.getDomHelper();
/**
* @type {goog.soy.InjectedDataSupplier}
* @private
*/
this.supplier_ = opt_injectedDataSupplier || null;
/**
* Map from template name to the data used to render that template.
* @type {!goog.soy.Renderer.SavedTemplateRender}
* @private
*/
this.savedTemplateRenders_ = [];
};
/**
* @typedef {Array.<{template: string, data: Object, ijData: Object}>}
*/
goog.soy.Renderer.SavedTemplateRender;
/**
* Renders a Soy template into a single node or a document fragment.
* Delegates to {@code goog.soy.renderAsFragment}.
*
* @param {Function} template The Soy template defining the element's content.
* @param {Object=} opt_templateData The data for the template.
* @return {!Node} The resulting node or document fragment.
*/
goog.soy.Renderer.prototype.renderAsFragment = function(template,
opt_templateData) {
this.saveTemplateRender_(template, opt_templateData);
return goog.soy.renderAsFragment(template, opt_templateData,
this.getInjectedData_(), this.dom_);
};
/**
* Renders a Soy template into a single node. If the rendered HTML
* string represents a single node, then that node is returned.
* Otherwise, a DIV element is returned containing the rendered nodes.
* Delegates to {@code goog.soy.renderAsElement}.
*
* @param {Function} template The Soy template defining the element's content.
* @param {Object=} opt_templateData The data for the template.
* @return {!Element} Rendered template contents, wrapped in a parent DIV
* element if necessary.
*/
goog.soy.Renderer.prototype.renderAsElement = function(template,
opt_templateData) {
this.saveTemplateRender_(template, opt_templateData);
return goog.soy.renderAsElement(template, opt_templateData,
this.getInjectedData_(), this.dom_);
};
/**
* Renders a Soy template and then set the output string as the
* innerHTML of the given element. Delegates to {@code goog.soy.renderElement}.
*
* @param {Element} element The element whose content we are rendering.
* @param {Function} template The Soy template defining the element's content.
* @param {Object=} opt_templateData The data for the template.
*/
goog.soy.Renderer.prototype.renderElement = function(element, template,
opt_templateData) {
this.saveTemplateRender_(template, opt_templateData);
goog.soy.renderElement(
element, template, opt_templateData, this.getInjectedData_());
};
/**
* Renders a Soy template and returns the output string.
* If the template is strict, it must be of kind HTML. To render strict
* templates of other kinds, use {@code renderText} (for {@code kind="text"}) or
* {@code renderStrict}.
*
* @param {Function} template The Soy template defining the element's content.
* @param {Object=} opt_templateData The data for the template.
* @return {string} The return value of rendering the template directly.
*/
goog.soy.Renderer.prototype.render = function(template, opt_templateData) {
var result = template(
opt_templateData || {}, undefined, this.getInjectedData_());
goog.asserts.assert(!(result instanceof goog.soy.data.SanitizedContent) ||
result.contentKind === goog.soy.data.SanitizedContentKind.HTML,
'render was called with a strict template of kind other than "html"' +
' (consider using renderText or renderStrict)');
this.saveTemplateRender_(template, opt_templateData);
return String(result);
};
/**
* Renders a strict Soy template of kind="text" and returns the output string.
* It is an error to use renderText on non-strict templates, or strict templates
* of kinds other than "text".
*
* @param {Function} template The Soy template defining the element's content.
* @param {Object=} opt_templateData The data for the template.
* @return {string} The return value of rendering the template directly.
*/
goog.soy.Renderer.prototype.renderText = function(template, opt_templateData) {
var result = template(
opt_templateData || {}, undefined, this.getInjectedData_());
goog.asserts.assertInstanceof(result, goog.soy.data.SanitizedContent,
'renderText cannot be called on a non-strict soy template');
goog.asserts.assert(
result.contentKind === goog.soy.data.SanitizedContentKind.TEXT,
'renderText was called with a template of kind other than "text"');
this.saveTemplateRender_(template, opt_templateData);
return String(result);
};
/**
* Renders a strict Soy template and returns the output SanitizedContent object.
*
* @param {function(Object.<string, *>, (null|undefined), Object.<string, *>):
* RETURN_TYPE} template The Soy template to render.
* @param {Object=} opt_templateData The data for the template.
* @param {goog.soy.data.SanitizedContentKind=} opt_kind The output kind to
* assert. If null, the template must be of kind="html" (i.e., opt_kind
* defaults to goog.soy.data.SanitizedContentKind.HTML).
* @return {RETURN_TYPE} The SanitizedContent object. This return type is
* generic based on the return type of the template, such as
* soy.SanitizedHtml.
* @template RETURN_TYPE
*/
goog.soy.Renderer.prototype.renderStrict = function(
template, opt_templateData, opt_kind) {
var result = template(
opt_templateData || {}, undefined, this.getInjectedData_());
goog.asserts.assertInstanceof(result, goog.soy.data.SanitizedContent,
'renderStrict cannot be called on a non-strict soy template');
goog.asserts.assert(
result.contentKind ===
(opt_kind || goog.soy.data.SanitizedContentKind.HTML),
'renderStrict was called with the wrong kind of template');
this.saveTemplateRender_(template, opt_templateData);
return result;
};
/**
* @return {!goog.soy.Renderer.SavedTemplateRender} Saved template data for
* the renders that have happened so far.
*/
goog.soy.Renderer.prototype.getSavedTemplateRenders = function() {
return this.savedTemplateRenders_;
};
/**
* Saves information about the current template render for debug purposes.
* @param {Function} template The Soy template defining the element's content.
* @param {Object=} opt_templateData The data for the template.
* @private
* @suppress {missingProperties} SoyJs compiler adds soyTemplateName to the
* template.
*/
goog.soy.Renderer.prototype.saveTemplateRender_ = function(
template, opt_templateData) {
if (goog.DEBUG) {
this.savedTemplateRenders_.push({
template: template.soyTemplateName,
data: opt_templateData,
ijData: this.getInjectedData_()
});
}
};
/**
* Creates the injectedParams map if necessary and calls the configuration
* service to prepopulate it.
* @return {Object} The injected params.
* @private
*/
goog.soy.Renderer.prototype.getInjectedData_ = function() {
return this.supplier_ ? this.supplier_.getData() : {};
};
/**
* An interface for a supplier that provides Soy injected data.
* @interface
*/
goog.soy.InjectedDataSupplier = function() {};
/**
* Gets the injected data. Implementation may assume that
* {@code goog.soy.Renderer} will treat the returned data as
* immutable. The renderer will call this every time one of its
* {@code render*} methods is called.
* @return {Object} A key-value pair representing the injected data.
*/
goog.soy.InjectedDataSupplier.prototype.getData = function() {};

View File

@@ -0,0 +1,205 @@
// Copyright 2011 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.
/**
* @fileoverview Provides utility methods to render soy template.
*/
goog.provide('goog.soy');
goog.require('goog.asserts');
goog.require('goog.dom');
goog.require('goog.dom.NodeType');
goog.require('goog.dom.TagName');
goog.require('goog.soy.data');
goog.require('goog.string');
/**
* @define {boolean} Whether to require all Soy templates to be "strict html".
* Soy templates that use strict autoescaping forbid noAutoescape along with
* many dangerous directives, and return a runtime type SanitizedContent that
* marks them as safe.
*
* If this flag is enabled, Soy templates will fail to render if a template
* returns plain text -- indicating it is a non-strict template.
*/
goog.define('goog.soy.REQUIRE_STRICT_AUTOESCAPE', false);
/**
* Renders a Soy template and then set the output string as
* the innerHTML of an element. It is recommended to use this helper function
* instead of directly setting innerHTML in your hand-written code, so that it
* will be easier to audit the code for cross-site scripting vulnerabilities.
*
* @param {Element} element The element whose content we are rendering into.
* @param {Function} template The Soy template defining the element's content.
* @param {Object=} opt_templateData The data for the template.
* @param {Object=} opt_injectedData The injected data for the template.
*/
goog.soy.renderElement = function(element, template, opt_templateData,
opt_injectedData) {
element.innerHTML = goog.soy.ensureTemplateOutputHtml_(template(
opt_templateData || goog.soy.defaultTemplateData_, undefined,
opt_injectedData));
};
/**
* Renders a Soy template into a single node or a document
* fragment. If the rendered HTML string represents a single node, then that
* node is returned (note that this is *not* a fragment, despite them name of
* the method). Otherwise a document fragment is returned containing the
* rendered nodes.
*
* @param {Function} template The Soy template defining the element's content.
* @param {Object=} opt_templateData The data for the template.
* @param {Object=} opt_injectedData The injected data for the template.
* @param {goog.dom.DomHelper=} opt_domHelper The DOM helper used to
* create DOM nodes; defaults to {@code goog.dom.getDomHelper}.
* @return {!Node} The resulting node or document fragment.
*/
goog.soy.renderAsFragment = function(template, opt_templateData,
opt_injectedData, opt_domHelper) {
var dom = opt_domHelper || goog.dom.getDomHelper();
var html = goog.soy.ensureTemplateOutputHtml_(
template(opt_templateData || goog.soy.defaultTemplateData_,
undefined, opt_injectedData));
goog.soy.assertFirstTagValid_(html);
return dom.htmlToDocumentFragment(html);
};
/**
* Renders a Soy template into a single node. If the rendered
* HTML string represents a single node, then that node is returned. Otherwise,
* a DIV element is returned containing the rendered nodes.
*
* @param {Function} template The Soy template defining the element's content.
* @param {Object=} opt_templateData The data for the template.
* @param {Object=} opt_injectedData The injected data for the template.
* @param {goog.dom.DomHelper=} opt_domHelper The DOM helper used to
* create DOM nodes; defaults to {@code goog.dom.getDomHelper}.
* @return {!Element} Rendered template contents, wrapped in a parent DIV
* element if necessary.
*/
goog.soy.renderAsElement = function(template, opt_templateData,
opt_injectedData, opt_domHelper) {
var dom = opt_domHelper || goog.dom.getDomHelper();
var wrapper = dom.createElement(goog.dom.TagName.DIV);
var html = goog.soy.ensureTemplateOutputHtml_(template(
opt_templateData || goog.soy.defaultTemplateData_,
undefined, opt_injectedData));
goog.soy.assertFirstTagValid_(html);
wrapper.innerHTML = html;
// If the template renders as a single element, return it.
if (wrapper.childNodes.length == 1) {
var firstChild = wrapper.firstChild;
if (firstChild.nodeType == goog.dom.NodeType.ELEMENT) {
return /** @type {!Element} */ (firstChild);
}
}
// Otherwise, return the wrapper DIV.
return wrapper;
};
/**
* Ensures the result is "safe" to insert as HTML.
*
* Note if the template has non-strict autoescape, the guarantees here are very
* weak. It is recommended applications switch to requiring strict
* autoescaping over time by tweaking goog.soy.REQUIRE_STRICT_AUTOESCAPE.
*
* In the case the argument is a SanitizedContent object, it either must
* already be of kind HTML, or if it is kind="text", the output will be HTML
* escaped.
*
* @param {*} templateResult The template result.
* @return {string} The assumed-safe HTML output string.
* @private
*/
goog.soy.ensureTemplateOutputHtml_ = function(templateResult) {
// Allow strings as long as strict autoescaping is not mandated. Note we
// allow everything that isn't an object, because some non-escaping templates
// end up returning non-strings if their only print statement is a
// non-escaped argument, plus some unit tests spoof templates.
// TODO(gboyer): Track down and fix these cases.
if (!goog.soy.REQUIRE_STRICT_AUTOESCAPE && !goog.isObject(templateResult)) {
return String(templateResult);
}
// Allow SanitizedContent of kind HTML.
if (templateResult instanceof goog.soy.data.SanitizedContent) {
templateResult = /** @type {!goog.soy.data.SanitizedContent} */ (
templateResult);
var ContentKind = goog.soy.data.SanitizedContentKind;
if (templateResult.contentKind === ContentKind.HTML) {
return goog.asserts.assertString(templateResult.content);
}
if (templateResult.contentKind === ContentKind.TEXT) {
// Allow text to be rendered, as long as we escape it. Other content
// kinds will fail, since we don't know what to do with them.
// TODO(gboyer): Perhaps also include URI in this case.
return goog.string.htmlEscape(templateResult.content);
}
}
goog.asserts.fail('Soy template output is unsafe for use as HTML: ' +
templateResult);
// In production, return a safe string, rather than failing hard.
return 'zSoyz';
};
/**
* Checks that the rendered HTML does not start with an invalid tag that would
* likely cause unexpected output from renderAsElement or renderAsFragment.
* See {@link http://www.w3.org/TR/html5/semantics.html#semantics} for reference
* as to which HTML elements can be parents of each other.
* @param {string} html The output of a template.
* @private
*/
goog.soy.assertFirstTagValid_ = function(html) {
if (goog.asserts.ENABLE_ASSERTS) {
var matches = html.match(goog.soy.INVALID_TAG_TO_RENDER_);
goog.asserts.assert(!matches, 'This template starts with a %s, which ' +
'cannot be a child of a <div>, as required by soy internals. ' +
'Consider using goog.soy.renderElement instead.\nTemplate output: %s',
matches && matches[0], html);
}
};
/**
* A pattern to find templates that cannot be rendered by renderAsElement or
* renderAsFragment, as these elements cannot exist as the child of a <div>.
* @type {!RegExp}
* @private
*/
goog.soy.INVALID_TAG_TO_RENDER_ =
/^<(body|caption|col|colgroup|head|html|tr|td|tbody|thead|tfoot)>/i;
/**
* Immutable object that is passed into templates that are rendered
* without any data.
* @type {Object}
* @private
*/
goog.soy.defaultTemplateData_ = {};

View File

@@ -0,0 +1,175 @@
// Copyright 2011 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.
/**
* @fileoverview Provides test helpers for Soy tests.
*/
/** @suppress {extraProvide} */
goog.provide('goog.soy.testHelper');
goog.setTestOnly('goog.soy.testHelper');
goog.require('goog.dom');
goog.require('goog.soy.data.SanitizedContent');
goog.require('goog.soy.data.SanitizedContentKind');
goog.require('goog.string');
goog.require('goog.userAgent');
goog.require('goog.dom.TagName');
/**
* Instantiable subclass of SanitizedContent.
*
* This is a spoof for sanitized content that isn't robust enough to get
* through Soy's escaping functions but is good enough for the checks here.
*
* @param {string} content The text.
* @param {goog.soy.data.SanitizedContentKind} kind The kind of safe content.
* @extends {goog.soy.data.SanitizedContent}
*/
function SanitizedContentSubclass(content, kind) {
// IMPORTANT! No superclass chaining to avoid exception being thrown.
this.content = content;
this.contentKind = kind;
}
goog.inherits(SanitizedContentSubclass, goog.soy.data.SanitizedContent);
function makeSanitizedContent(content, kind) {
return new SanitizedContentSubclass(content, kind);
}
//
// Fake Soy-generated template functions.
//
var example = {};
example.textNodeTemplate = function(opt_data, opt_sb, opt_injectedData) {
assertNotNull(opt_data);
assertNotUndefined(opt_data);
return goog.string.htmlEscape(opt_data.name);
};
example.singleRootTemplate = function(opt_data, opt_sb, opt_injectedData) {
assertNotNull(opt_data);
assertNotUndefined(opt_data);
return '<span>' + goog.string.htmlEscape(opt_data.name) + '</span>';
};
example.multiRootTemplate = function(opt_data, opt_sb, opt_injectedData) {
assertNotNull(opt_data);
assertNotUndefined(opt_data);
return '<div>Hello</div><div>' + goog.string.htmlEscape(opt_data.name) +
'</div>';
};
example.injectedDataTemplate = function(opt_data, opt_sb, opt_injectedData) {
assertNotNull(opt_data);
assertNotUndefined(opt_data);
return goog.string.htmlEscape(opt_data.name) +
goog.string.htmlEscape(opt_injectedData.name);
};
example.noDataTemplate = function(opt_data, opt_sb, opt_injectedData) {
assertNotNull(opt_data);
assertNotUndefined(opt_data);
return '<div>Hello</div>';
};
example.sanitizedHtmlTemplate = function(opt_data, opt_sb, opt_injectedData) {
// Test the SanitizedContent constructor.
return makeSanitizedContent('Hello World',
goog.soy.data.SanitizedContentKind.HTML);
};
example.sanitizedHtmlAttributesTemplate =
function(opt_data, opt_sb, opt_injectedData) {
return makeSanitizedContent('foo="bar"',
goog.soy.data.SanitizedContentKind.ATTRIBUTES);
};
example.sanitizedCssTemplate =
function(opt_data, opt_sb, opt_injectedData) {
return makeSanitizedContent('display:none',
goog.soy.data.SanitizedContentKind.CSS);
};
example.unsanitizedTextTemplate =
function(opt_data, opt_sb, opt_injectedData) {
return makeSanitizedContent('I <3 Puppies & Kittens',
goog.soy.data.SanitizedContentKind.TEXT);
};
example.templateSpoofingSanitizedContentString =
function(opt_data, opt_sb, opt_injectedData) {
return makeSanitizedContent('Hello World',
// This is to ensure we're using triple-equals against a unique Javascript
// object. For example, in Javascript, consider ({}) == '[Object object]'
// is true.
goog.soy.data.SanitizedContentKind.HTML.toString());
};
example.tableRowTemplate = function(opt_data, opt_sb, opt_injectedData) {
return '<tr><td></td></tr>';
};
example.colGroupTemplateCaps = function(opt_data, opt_sb, opt_injectedData) {
return '<COLGROUP></COLGROUP>';
};
//
// Test helper functions.
//
/**
* Retrieves the content of document fragment as HTML.
* @param {Node} fragment The document fragment.
* @return {string} Content of the document fragment as HTML.
*/
function fragmentToHtml(fragment) {
var testDiv = goog.dom.createElement(goog.dom.TagName.DIV);
testDiv.appendChild(fragment);
return elementToInnerHtml(testDiv);
}
/**
* Retrieves the content of an element as HTML.
* @param {Element} elem The element.
* @return {string} Content of the element as HTML.
*/
function elementToInnerHtml(elem) {
var innerHtml = elem.innerHTML;
if (goog.userAgent.IE) {
innerHtml = innerHtml.replace(/DIV/g, 'div').replace(/\s/g, '');
}
return innerHtml;
}