Blueprint

How to get Blueprint

ES2015+:

import Blueprint from 'fontoxml-blueprints/Blueprint'

ES5:

define([
	'fontoxml-blueprints/Blueprint'
], function (
	Blueprint
) {
});

Type: Class

A blueprint provides a layer over the actual dom in which it is possible to change the structure without affecting the actual document.

Besides this, it is possible to make new overlays in which mutations can be made, validated, and possibly be reverted. This is especially useful when writing mutations which have to try multiple things.

Constructor

# Name Type Description
1. dom Dom | LocalDom

The dom on which this blueprint operates. Accepts both the global Dom as well as a LocalDom proxy for backwards compatibility.

Methods

Name Description
adoptNode

Moves node from another document and returns it. This makes configuration from the new document apply to node.

In general it is not necessary to call adoptNode, as moving the node to a new document will do this automatically, and most configuration-dependent APIs (including validation) will not work reliably for nodes that are not in a document tree.


  Arguments
# Name Type Description
1. document Document
2. node Node
  Returns

Type: Node

appendChild

Append a child to the parentNode, inserting it as the last child. Shorthand for insertBefore(parentnode, node, null);


  Arguments
# Name Type Description
1. parentNode Node

The node to append the child to

2. node Node

The node to append

  Returns

Type: Node

The inserted node

applyOverlay

Makes all mutations performed during the current overlay permanent.

beginOverlay

Begins a blueprint overlay. All operations performed while an overlay is active can be reversed if the overlay is discarded or made permanent if the overlay is accepted.

cloneNode

Create a full clone from the given node, from the context in this blueprint.

Because of the implementation of nodeId, the userData will not be cloned.


  Arguments
# Name Type Description
1. node Node

The node to clone

2. deep Boolean

Whether the children of the node should be cloned too

  Returns

Type: Node

The clone of the given node

discardOverlay

Discards all mutations performed during the current overlay, reverting the Blueprint to the state before the overlay was started.

getAllAttributes

Get all the attributes of this node, including attributes which are only known in the Blueprint


  Arguments
# Name Type Description
1. node Node

The node from which to get all of the attributes

  Returns

Type: Array<Attr>

The attributes of the given node, as an array of Attribute nodes

getAttribute

Returns the value of the given node's attribute with the given name


  Arguments
# Name Type Description
1. node Node

Node for which to retrieve the attribute value

2. qualifiedName String

Name of the attribute to be retrieved

  Returns

Type: String | Null

The value of the given attribute, or null if the attribute does not exist.

getAttributeNodeNS

Returns node's attribute with the given namespace and local name


  Arguments
# Name Type Description
1. node Node

The node to get the attribute node from

2. namespaceURI String | Null

The namespace uri of the attribute

3. localName String

the local name of the attribute

  Returns

Type: Attr | Null

The value of the given attribute, or null if the attribute does not exist.

getAttributeNS

Returns the value of the given node's attribute with the given namespace and local name


  Arguments
# Name Type Description
1. node Node

The node to get the attribute node from

2. namespaceURI String | Null

The namespace uri of the attribute

3. localName String

the local name of the attribute

  Returns

Type: String | Null

The value of the given attribute, or null if the attribute does not exist.

getChildNodes

Returns the child nodes of the given node according to the blueprint.


  Arguments
# Name Type Description
1. node Node

The node for which to retrieve the child nodes

  Returns

Type: Array<Node>

The child nodes of the given node

getData

Returns the data for the given node according to the Blueprint.


  Arguments
# Name Type Description
1. node Node

The node for which to retrieve the data

  Returns

Type: String

The data for the given node

getFirstChild

Returns the first child of the given node according to the blueprint.


  Arguments
# Name Type Description
1. node Node

The node for which to retrieve the first child

  Returns

Type: Node | Null

The first child of the given node, or null if there is none

getLastChild

Returns the last child of the given node according to the blueprint.


  Arguments
# Name Type Description
1. node Node

The node for which to retrieve the last child

  Returns

Type: Node | Null

The last child of the given node, or null if there is none

getNextSibling

Returns the next sibling of the given node according to the blueprint.


  Arguments
# Name Type Description
1. node Node

The node for which to retrieve the next sibling

  Returns

Type: Node | Null

The next sibling of the given node, or null if there is none

getOwnerDocument

Returns the owner document of the given node according to the blueprint.

If the node is itself a Document, the owner document is null. Use blueprintQuery.getDocumentNode if you want the node itself in that case.


  Arguments
# Name Type Description
1. node Node
  Returns

Type: Document | Null

getParentNode

Returns the parent node of the given node according to the blueprint.

If the node is an attribute, the ownerElement is returned.


  Arguments
# Name Type Description
1. node Node

The node for which to retrieve the parent node

  Returns

Type: Node | Null

The parent node of the given node, or null if there is none

getPreviousSibling

Returns the previous sibling of the given node according to the blueprint.


  Arguments
# Name Type Description
1. node Node

The node for which to retrieve the previous sibling

  Returns

Type: Node | Null

The previous sibling of the given node, or null if there is none

insertBefore

Inserts the given node at the given position in the DOM represented by the Blueprint.


  Arguments
# Name Type Description
1. parentNode Node

Parent node under which to insert the new node

2. newNode Node

The new node to insert

3. referenceNode Node | Null

Node which should become the next sibling of the new node.

  Returns

Type: Node

The new node

lookup

Look up the node with the given ID.


  Arguments
# Name Type Description
1. nodeId NodeId

The node ID to look up

  Returns

Type: Node

The Node with the given ID

removeAttribute

Removes the given node's attribute with the given name.


  Arguments
# Name Type Description
1. node Node

Node for which to set the attribute value

2. qualifiedName String

Name of the attribute to be removed

removeAttributeNode

Removes the given node's attribute


  Arguments
# Name Type Description
1. node Element
2. attribute Attribute
removeAttributeNS

Removes the given node's attribute with the given namespace and local name


  Arguments
# Name Type Description
1. node Node
2. namespaceURI String | Null
3. localName String
removeChild

Removes the given node from its parent in the DOM represented by the Blueprint.


  Arguments
# Name Type Description
1. parentNode Node

Parent node from which to remove the node

2. node Node

The node to remove

  Returns

Type: Node

The removed node

replaceChild

Replaces the given node with another node in the DOM represented by the Blueprint.


  Arguments
# Name Type Description
1. parentNode Node

Parent node under which to replace the node

2. newNode Node

The new node to insert

3. oldNode Node

The node to remove

  Returns

Type: Node

The removed node

setAttributeNS

Sets the value of the given node's attribute with the given namespace and qualified name to the given value.


  Arguments
# Name Type Description
1. node Node
2. namespaceURI String | Null
3. qualifiedName String
4. attributeValue String
setData

Sets the data for the given node according to the Blueprint.


  Arguments
# Name Type Description
1. node CharacterData

The node for which to set the data. This should be a CharacterData node, like a Text node, a Comment node or a ProcessingInstruction node.

2. data String

The new data for the node

splitText

Splits the given text node in two.

Positions in node beyond the split point will be moved into the second half. The position at the split point remains at the end of node.


  Arguments
# Name Type Description
1. node Node

The text node to split

2. offset Number

Index of the first character in node's data after the split

  Returns

Type: Node

The second half after the split (the given node becomes the first half).

Related links