- Source:
Members
-
<inner> booleanAttrs
-
Attributes that are to be serialized like checked="checked" for any attribute value.
- Source:
-
<inner> emptyElements
-
Elements that are to be serialized like
and not like
.
- Source:
-
<inner> isUnrecognizedMap
-
Maps element names to a boolean that indicates whether IE7/IE8 doesn't recognize the element. This is necessary to repair the broken DOM structure caused by unrecognized elements. Contains some intial values to cover most common cases. If an element is serialized that is not present here, it will be examined (which may be costly) and added dynamically. See isUnrecognized().
- Source:
Methods
-
<inner> contentsToXhtml(nodes, ephemera) → {string}
-
Serializes a number of DOM nodes in an array-like object to an XHTML string. The XHTML of the nodes in the given array-like object will be concatenated.
Parameters:
Name Type Description nodes
Array.<Node> An array or jQuery object or another array-like object to serialize. ephemera
Object Describes content that should not be serialized. Only attrMap and attrRxs are supported at the moment. See ephemera.ephemera(). - Source:
- See:
-
- nodeToXhtml()
Returns:
The serialized XHTML String representing the given DOM nodes in the given array-like object. The result may look like an XML fragment with multiple top-level elements and text nodes.- Type
- string
-
<inner> encodeDqAttrValue(str) → {string}
-
Encodes a string meant to be used between double-quoted attribute values.
Parameters:
Name Type Description str
string An unencoded attribute value. - Source:
Returns:
The given string with & < and " characters replaced with the corresponding HTML entity references.- Type
- string
-
<inner> encodePcdata(str) → {string}
-
Encodes a string meant to be used wherever parsable character data occurs in XML.
Parameters:
Name Type Description str
string An unencoded piece of character data. - Source:
Returns:
The given string with & and < characters replaced with the corresponding HTML entity references.- Type
- string
-
<inner> isUnrecognized(element) → {boolean}
-
IE8 turns the following
{content} into{content}/book> This seems to occur with any element IE doesn't recognize. Parameters:
Name Type Description element
Element An element node. - Source:
Returns:
True if the given element isn't recognized by IE and causes a broken DOM structure as outlined above.- Type
- boolean
-
<inner> makeAttrString(element, ephemera) → {string}
-
Serializes the attributes of the given element. Attributes that have the empty string as value will not appear in the string at all.
Parameters:
Name Type Description element
Element An element to serialize the attributes of. ephemera
Object Describes attributes that should be skipped. See Ehpemera.ephemera(). - Source:
Returns:
A string made up of name="value" for each attribute of the given element, separated by space. The string will have a leading space.- Type
- string
-
<inner> nodeToXhtml(node, ephemera) → {string}
-
Serializes a DOM node to an XHTML string. Beware that the serialization method will generate XHTML as close as possible to the DOM tree represented by the given node. The result will only be valid XHTML if the DOM tree doesn't violate any contained-in rules. Element attributes with an empty string as value will not appear in the serialized output. Element attribute names are case-insensitive in HTML5, so they may come out in mixed-case depending on what the browser provides. When iterating over the DOM, CDATA sections are comment nodes on some browsers (Chrome) and not there at all on others (IE). This is the same as what comes out from element.innerHTML. IE8 bug: comments will sometimes be silently stripped inside contentEditable=true. Conditional includes don't work inside contentEditable=true. See the tests for more information. IE8 bug: a title element will not be serialized correctly unless it occurs in the head of a HTML document, even if it occurs in a non-HTML namespace (maybe it works with a prefix). This will probably also apply for other HTML elements that occur in the header. IE8 bug: unrecognized elements in the HTML scope will cause broken DOM structure (some HTML5 elements that are not yet implemented in IE for example). Some effort was made to fix a broken DOM structure, if it is encountered. There is one case which results in an unrecoverably broken DOM structure, which is an unrecognized element not preceded by some text. See the tests for further information. IE8 bug: whitespace is not reliably preserved when the style white-space:pre (or similar) is used. See the tests for further information. Whitespace inside
elements will be preserved, but \n characters will become \r characters. IE7 bug: URLs in href and src attributes of a and img elements will be absolutized (including hostname and protocol) if they are given as a relative path. IE bug: Namespace support inside contentEditable=true is a bit shaky on IE. Don't use it if possible. See the tests to get an idea of what seems to work. Make namespace prefixes and element names all lower-case, as they are always lower-cased, even if the element doesn't occur in an HTML namespace. Don't use default namespaces, use prefixes (except for an HTML namespace).
Parameters:
Name Type Description node
Node A DOM node to serialize. ephemera
Object Describes content that should not be serialized. Only attrMap and attrRxs are supported at the moment. See ephemera.ephemera(). - Source:
Returns:
The serialized XHTML string represnting the given DOM node.- Type
- string
-
<inner> serialize(node, ephemera, xhtml)
-
Serializes a DOM node into a XHTML string.
Parameters:
Name Type Description node
DomEvents A DOM node to serialize. ephemera
Object Describes content that should not be serialized. Only attrMap and attrRxs are supported at the moment. See ephemera.ephemera(). xhtml
Array An array that will receive snippets of XHTML, which if joined will yield the XHTML string. - Source:
-
<inner> serializeChildren()
-
Serializes the children of the given element into an XHTML string. The same as serializeElement() except it only serializes the children. The start and end tag of the given element will not appear in the resulting XHTML.
- Source:
- See:
-
- serializeElement()
-
<inner> serializeElement(element, child, unrecognized, ephemera, xhtml) → {Element}
-
Serializes an element into an XHTML string.
Parameters:
Name Type Description element
Element An element to serialize. child
Element The first child of the given element. This will usually be element.firstChild. On IE this may be element.nextSibling because of the broken DOM structure IE sometimes generates. unrecognized
boolean Whether the given element is unrecognized on IE. If IE doesn't recognize the element, it will create a broken DOM structure which has to be compensated for. See isUnrecognized() for more. ephemera
Object Describes content that should not be serialized. Only attrMap and attrRxs are supported at the moment. See ephemera.ephemera(). xhtml
Array An array which receives the serialized element and which, if joined, will yield the XHTML string. - Source:
Returns:
null if all siblings of the given child have been processed as children of the given element, or otherwise the first sibling of child that is not considered a child of the given element.- Type
- Element