incremental-dom
- Version 0.7.0
- Published
- 191 kB
- No dependencies
- Apache-2.0 license
Install
npm i incremental-dom
yarn add incremental-dom
pnpm add incremental-dom
Overview
An in-place virtual DOM library
Index
Variables
Functions
- alignWithDOM()
- applyAttr()
- applyAttrs()
- applyProp()
- applyStatics()
- attr()
- clearCache()
- close()
- createPatchInner()
- createPatchOuter()
- currentElement()
- currentPointer()
- elementClose()
- elementOpen()
- elementOpenEnd()
- elementOpenStart()
- elementVoid()
- getKey()
- importNode()
- isDataInitialized()
- key()
- open()
- patch()
- patchInner()
- patchOuter()
- setKeyAttributeName()
- skip()
- skipNode()
- text()
Interfaces
Type Aliases
Variables
variable attributes
const attributes: AttrMutatorConfig;
A publicly mutable object to provide custom mutators for attributes. NB: The result of createMap() has to be recast since closure compiler will just assume attributes is "any" otherwise and throws away the type annotation set by tsickle.
variable notifications
const notifications: Notifications;
variable symbols
const symbols: { default: string };
Copyright 2018 The Incremental DOM 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.
Functions
function alignWithDOM
alignWithDOM: (nameOrCtor: NameOrCtorDef, key: Key) => void;
Aligns the virtual Node definition with the actual DOM, moving the corresponding DOM node to the correct location or creating it if necessary.
Parameter nameOrCtor
The name or constructor for the Node.
Parameter key
The key used to identify the Node.
function applyAttr
applyAttr: (el: Element, name: string, value: unknown) => void;
Applies an attribute or property to a given Element. If the value is null or undefined, it is removed from the Element. Otherwise, the value is set as an attribute.
Parameter el
The element to apply the attribute to.
Parameter name
The attribute's name.
Parameter value
The attribute's value.
function applyAttrs
applyAttrs: () => void;
Applies the currently buffered attrs to the currently open element. This clears the buffered attributes.
function applyProp
applyProp: (el: Element, name: string, value: unknown) => void;
Applies a property to a given Element.
Parameter el
The element to apply the property to.
Parameter name
The property's name.
Parameter value
The property's value.
function applyStatics
applyStatics: (statics: {}[]) => void;
Applies the current static attributes to the currently open element. Note: statics should be applied before calling
applyAtrs
.Parameter statics
The statics to apply to the current element.
function attr
attr: (name: string, value: any) => void;
Buffers an attribute, which will get applied during the next call to
elementOpen
,elementOpenEnd
orapplyAttrs
.Parameter name
The of the attribute to buffer.
Parameter value
The value of the attribute to buffer.
function clearCache
clearCache: (node: Node) => void;
Clears all caches from a node and all of its children.
Parameter node
The Node to clear the cache for.
function close
close: () => Element;
Closes the currently open Element, removing any unvisited children if necessary.
Returns
The Element that was just closed.
function createPatchInner
createPatchInner: <T>(patchConfig?: PatchConfig) => PatchFunction<T, Node>;
Creates a patcher that patches the document starting at node with a provided function. This function may be called during an existing patch operation.
Parameter patchConfig
The config to use for the patch.
Returns
The created function for patching an Element's children.
function createPatchOuter
createPatchOuter: <T>( patchConfig?: PatchConfig) => PatchFunction<T, Node | null>;
Creates a patcher that patches an Element with the the provided function. Exactly one top level element call should be made corresponding to
node
.Parameter patchConfig
The config to use for the patch.
Returns
The created function for patching an Element.
function currentElement
currentElement: () => Element;
Returns
The current Element being patched.
function currentPointer
currentPointer: () => Node;
The Node that will be evaluated for the next instruction.
function elementClose
elementClose: (nameOrCtor: NameOrCtorDef) => Element;
Closes an open virtual Element.
Parameter nameOrCtor
The Element's tag or constructor. The corresponding Element.
function elementOpen
elementOpen: ( nameOrCtor: NameOrCtorDef, key?: Key, statics?: {}[], ...varArgs: Array<any>) => HTMLElement;
Parameter nameOrCtor
The Element's tag or constructor.
Parameter key
The key used to identify this element. This can be an empty string, but performance may be better if a unique value is used when iterating over an array of items.
Parameter statics
An array of attribute name/value pairs of the static attributes for the Element. Attributes will only be set once when the Element is created.
Parameter varArgs
, Attribute name/value pairs of the dynamic attributes for the Element. The corresponding Element.
function elementOpenEnd
elementOpenEnd: () => HTMLElement;
Closes an open tag started with elementOpenStart. The corresponding Element.
function elementOpenStart
elementOpenStart: (nameOrCtor: NameOrCtorDef, key?: Key, statics?: {}[]) => void;
Declares a virtual Element at the current location in the document. This corresponds to an opening tag and a elementClose tag is required. This is like elementOpen, but the attributes are defined using the attr function rather than being passed as arguments. Must be folllowed by 0 or more calls to attr, then a call to elementOpenEnd.
Parameter nameOrCtor
The Element's tag or constructor.
Parameter key
The key used to identify this element. This can be an empty string, but performance may be better if a unique value is used when iterating over an array of items.
Parameter statics
An array of attribute name/value pairs of the static attributes for the Element. Attributes will only be set once when the Element is created.
function elementVoid
elementVoid: ( nameOrCtor: NameOrCtorDef, key?: Key, statics?: {}[], ...varArgs: Array<any>) => Element;
Declares a virtual Element at the current location in the document that has no children.
Parameter nameOrCtor
The Element's tag or constructor.
Parameter key
The key used to identify this element. This can be an empty string, but performance may be better if a unique value is used when iterating over an array of items.
Parameter statics
An array of attribute name/value pairs of the static attributes for the Element. Attributes will only be set once when the Element is created.
Parameter varArgs
Attribute name/value pairs of the dynamic attributes for the Element. The corresponding Element.
function getKey
getKey: (node: Node) => Key;
Gets the key for a Node. note that the Node should have been imported by now.
Parameter node
The node to check.
Returns
The key used to create the node.
function importNode
importNode: (node: Node) => void;
Imports node and its subtree, initializing caches.
Parameter node
The Node to import.
function isDataInitialized
isDataInitialized: (node: Node) => boolean;
Parameter node
The node to check.
Returns
True if the NodeData already exists, false otherwise.
function key
key: (key: string) => void;
Allows you to define a key after an elementOpenStart. This is useful in templates that define key after an element has been opened ie
<div key('foo')></div>
.Parameter key
The key to use for the next call.
function open
open: (nameOrCtor: NameOrCtorDef, key?: Key) => HTMLElement;
Makes sure that the current node is an Element with a matching nameOrCtor and key.
Parameter nameOrCtor
The tag or constructor for the Element.
Parameter key
The key used to identify this element. This can be an empty string, but performance may be better if a unique value is used when iterating over an array of items. The corresponding Element.
function patch
patch: <T>( node: Element | DocumentFragment, template: (a: T) => void, data?: T) => Node;
function patchInner
patchInner: <T>( node: Element | DocumentFragment, template: (a: T) => void, data?: T) => Node;
function patchOuter
patchOuter: <T>( node: Element | DocumentFragment, template: (a: T) => void, data?: T) => Node | null;
function setKeyAttributeName
setKeyAttributeName: (name: string | null) => void;
function skip
skip: () => void;
Skips the children in a subtree, allowing an Element to be closed without clearing out the children.
function skipNode
skipNode: () => void;
Changes to the next sibling of the current node.
function text
text: ( value: string | number | boolean, ...varArgs: ((a: {}) => string)[]) => Text;
Declares a virtual Text at this point in the document.
Parameter value
The value of the Text.
Parameter varArgs
Functions to format the value which are called only when the value has changed. The corresponding text node.
Interfaces
interface AttrMutatorConfig
interface AttrMutatorConfig {}
index signature
[x: string]: AttrMutator;
interface ElementConstructor
interface ElementConstructor {}
Copyright 2018 The Incremental DOM 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.
construct signature
new (): Element;
interface PatchConfig
interface PatchConfig {}
property matches
matches?: MatchFnDef;
Type Aliases
type AttrMutator
type AttrMutator = (a: Element, b: string, c: any) => void;
type Key
type Key = string | number | null | undefined;
type MatchFnDef
type MatchFnDef = ( matchNode: Node, nameOrCtor: NameOrCtorDef, expectedNameOrCtor: NameOrCtorDef, key: Key, expectedKey: Key) => boolean;
type NameOrCtorDef
type NameOrCtorDef = string | ElementConstructor;
type PatchFunction
type PatchFunction<T, R> = ( node: Element | DocumentFragment, template: (a: T | undefined) => void, data?: T | undefined) => R;
type Statics
type Statics = Array<{}> | null | undefined;
Package Files (9)
Dependencies (0)
No dependencies.
Dev Dependencies (23)
- @bazel/bazel
- @bazel/ibazel
- @bazel/karma
- @bazel/typescript
- @types/mocha
- @types/sinon
- @types/sinon-chai
- @typescript-eslint/eslint-plugin
- @typescript-eslint/parser
- chai
- eslint
- eslint-config-prettier
- eslint-plugin-prettier
- karma
- karma-chrome-launcher
- karma-firefox-launcher
- mocha
- npm-check
- prettier
- sinon
- sinon-chai
- typescript
- uglify-js
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/incremental-dom
.
- Markdown[![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/incremental-dom)
- HTML<a href="https://www.jsdocs.io/package/incremental-dom"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 4269 ms. - Missing or incorrect documentation? Open an issue for this package.