-
<inner> attributes()
-
Registers ephemeral attributes by attribute name.
Similar to classes() except applies to entire attributes instead of
individual classes in the class attribute.
- Source:
-
<inner> checkCommonSubstr()
-
Checks whether the given classes contain the substring common to all
ephemeral classes. If the check fails, an warning will be logged and the
substring will be set to the empty string which voids the performance
improvement the common substring would otherwise have gained.
- Source:
-
<inner> classes()
-
Registers ephemeral classes.
An ephemeral class is a non-content class that will be pruned from the
from the result of editable.getContents().
The given classes should contain the string 'aloha-' to get the benefit
of a performance optimization.
Returns a map that contains all classes that were ever registered with
this function.
Multiple classes may be specified. If none are specified, just returns
the current ephemeral classes map without modifying it.
Also see ephemera().
- Source:
-
<inner> ephemera()
-
Provides access to the global ephemera registry.
If the given argument is not null, sets the global ephemera registry to
the given value and returns it. Otherwise, just returns the global
registry.
The given/returned value has the following properties:
The given map may have the following entries
classMap - a map from class name to the value true.
all classes must have a "aloha-" prefix.
Use Ehpemera.attributes() to set classes without "aloha-" prefix.
attrMap - a map from attribute name to the value true or to an array of
element names. If an array of elements is specified, the
attribute will only be considered ephemeral if it is found on
an element in the array.
attrRxs - an array of regexes (in object - not string - form: /[a-z].../)
pruneFns - an array of functions that will be called at each pruning step.
When a DOM tree is pruned with prune(elem) without an emap argument, the
global registry maintained with classes() attributes() and ephemera() is
used as a default map. If an emap argument is specified, the global
registry will be ignored and the emap argument will be used instead.
When a DOM tree is pruned with prune()
- classes specified by classMap will be removed
- attributes specified by attrMap or attrRxs will be removed
- functions specified by pruneFns will be called as the DOM tree is
descended into (pre-order), with each node (element, text, etc.) as a
single argument. The function is free to modify the element and return
it, or return a new element which will replace the given element in the
pruned tree. If null or undefined is returned, the element will be
removed from the tree. As per contract of maps.walkDomInplace, it is
allowed to insert/remove children in the parent node as long as the
given node is not removed.
Also see classes() and attributes().
Note that removal of attributes doesn't always work on IE7 (in rare
special cases). The dom-to-xhtml plugin can reliably remove ephemeral
attributes during the serialization step.
- Source:
-
<inner> isAttrEphemeral()
-
Determines whether the given attribute of the given element is ephemeral
according to the given emap.
See Ephemera.ephemera() for an explanation of attrMap and attrRxs.
- Source:
-
<inner> markAttr()
-
Marks the attribute of an element as ephemeral.
The attribute will be removed from the element when the prune function is
called on it.
Multiple attributes can be passed at the same time be separating them
with a space.
Adds the class 'aloha-ephemera-attr' to the given element. Also adds or
modifies the 'data-aloha-ephemera-attr' attribute, and adds to it the
name of the given attribute.
These modifications can be made directly without recurse to this
function, if that is more convenient.
- Source:
-
<inner> markElement()
-
Marks an element as ephemeral.
The element will be completely removed when the prune function is called
on it.
Adds the class 'aloha-ephemera' to the given element.
The class 'aloha-ephemera' can also be added directly without recurse to
this function, if that is more convenient.
- Source:
-
<inner> markFiller()
-
Marks an element as ephemeral, excluding subnodes.
Adds the class 'aloha-ephemera-filler' to the given element.
The class 'aloha-ephemera-filler' may also be added directly,
without recurse to this function, if that is more convenient.
See wrapper()
- Source:
-
<inner> markWrapper()
-
Marks an element as a ephemeral, excluding subnodes.
The element will be removed when the prune function is called on it, but
any children of the wrapper element will remain in its place.
A wrapper is an element that wraps a single non-ephemeral element. A
filler is an element that is wrapped by a single non-ephemeral element.
This distinction is not important for the prune function, which behave
the same for both wrappers and fillers, but it makes it easier to build
more advanced content inspection algorithms (also see note at the header
of ephemeral.js).
Adds the class 'aloha-ephemera-wrapper' to the given element.
The class 'aloha-ephemera-wrapper' may also be added directly, without
recurse to this function, if that is more convenient.
NB: a wrapper element must not wrap a filler element. Wrappers and
fillers are ephermeral. A wrapper must always wrap a single
_non-ephemeral_ element, and a filler must always fill a single
_non-ephemeral_ element.
- Source:
-
<inner> prune()
-
Prunes the given element of all ephemeral data.
Elements marked with Ephemera.markElement() will be removed.
Attributes marked with Ephemera.markAttr() will be removed.
Elements marked with Ephemera.markWrapper() or Ephemera.markFiller() will
be replaced with their children.
See ephemera() for an explanation of the emap argument.
All properties of emap, if specified, are required, but may be empty.
The element is modified in-place and returned.
- Source:
-
<inner> pruneElem()
-
Prunes an element of attributes and classes or removes the element by
returning false.
Elements attributes and classes can either be marked as ephemeral, in
which case the element itself will contain the prune-info, or they can be
specified as ephemeral with the given emap.
See ephemera() for an explanation of the emap argument.
- Source:
-
<inner> pruneEmapAttrs()
-
Prunes attributes specified with either emap.attrMap or emap.attrRxs.
See ephemera().
- Source:
-
<inner> pruneMarkedAttrs()
-
Prunes attributes marked as ephemeral with Ephemera.attributes() from the
given element.
- Source: