goog.html.sanitizer.noclobber
Module ID |
---|
Utility DOM functions resistant to DOM clobbering. Clobbering resistance is offered as a best-effort feature -- it is not available on older browsers such as IE <10, Chrome <43, etc. In some cases, we can at least detect clobbering attempts and abort. Note that this is not intended to be a general-purpose library -- it is only used by the HTML sanitizer to accept and sanitize clobbered input. If your projects needs to protect against clobbered content, consider using the HTML sanitizer and configuring it to defuse clobbering by prefixing all element ids and names in the output.
Exported Functions
appendNodeChild( parent, child ) → Node
Node
Appends a child to a node without falling prey to things like
.Parameters |
| ||||||||
---|---|---|---|---|---|---|---|---|---|
Returns |
|
assertNodeIsElement( node ) → Element
Element
Asserts that a Node is an Element, without falling prey to things like
.Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
elementMatches( element, selector ) → boolean
boolean
getChildNodes( node ) → NodeList<Node>
NodeList<Node>
Returns the value of node.childNodes without falling prey to things like
.Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
getCssPropertyValue( cssStyle, propName ) → string
string
getElementAttribute( element, attrName ) → (string|null)
(string|null)
getElementAttributes( element ) → NamedNodeMap
NamedNodeMap
Returns an element's attributes without falling prey to things like
. Equivalent to `node.attributes`.Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
getElementInnerHTML( element ) → string
string
Returns a node's innerHTML property value without falling prey to things like
. Equivalent to `element.innerHTML`.Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
getElementNamespaceURI( element ) → string
string
Returns an element's namespace URI without falling prey to things like
.Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
getElementStyle( element ) → CSSStyleDeclaration
CSSStyleDeclaration
Returns an element's style without falling prey to things like
.Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
getElementStyleSheet( element ) → CSSStyleSheet
CSSStyleSheet
Returns an element's style without falling prey to things like
.Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
getElementsByTagName( element, name ) → Array<Element>
Array<Element>
getNodeName( node ) → string
string
Returns a node's nodeName without falling prey to things like
.Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
getNodeType( node ) → number
number
Returns a node's nodeType without falling prey to things like
<form><input name="nodeType"></form>
.
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
getParentNode( node ) → (Node|null)
(Node|null)
Returns a node's parentNode without falling prey to things like
.Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
hasElementAttribute( element, attrName ) → boolean
boolean
isNodeElement( node ) → boolean
boolean
Returns whether the node is an Element, without falling prey to things like
.Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
removeElementAttribute( element, attrName ) → void
void
Deletes a specific attribute from an element without falling prey to things like
. Equivalent toelement.removeAttribute("foo")
.
Parameters |
|
---|
setCssProperty( cssStyle, propName, sanitizedValue ) → void
void
setElementAttribute( element, name, value ) → void
void