    import DomBinding from 'yjs/src/Bindings/DomBinding/DomBinding.js'

public class | source

# DomBinding

#### Extends:

Binding → DomBinding

A binding that binds the children of a YXmlFragment to a DOM element.

This binding is automatically destroyed when its parent is deleted.

#### Example:

    const div = document.createElement('div')
    const type = y.define('xml', Y.XmlFragment)
    const binding = new Y.QuillBinding(type, div)

## Constructor Summary

Public Constructor
public | constructor (type: YXmlFragment, target: Element, opts: Object) |

## Member Summary

Public Members
public | domToType : Map Maps each DOM element to the type that it is associated with. |
public | filter : FilterFunction Defines which DOM attributes and elements to filter out. |
public | opts : * |
public | typeToDom : Map Maps each YXml type to the DOM element that it is associated with. |

## Method Summary

Public Methods
public | destroy () Remove all properties that are handled by this class. |
public | enableSmartScrolling (scrollElement: Element) Enables the smart scrolling functionality for a Dom Binding. |
public | setFilter (filter: FilterFunction) NOTE: currently does not apply filter to existing elements! |

## Inherited Summary

From class Binding
public | target : * The target that `type` is bound to. |
public | type : YType The Yjs type that is bound to `target` |
public | destroy () Remove all data observers (both from the type and the target). |

## Public Constructors

### public constructor(type: YXmlFragment, target: Element, opts: Object) source

#### Override:

Binding#constructor

#### Params:

Name | Type | Attribute | Description
type | YXmlFragment |  | The bind source. This is the ultimate source of truth.
target | Element |  | The bind target. Mirrors the target.

opts

Object

- optional

Optional configurations

opts.filter

FilterFunction

- optional
- default: defaultFilter

The filter function to use.

## Public Members

### public domToType: Map source

Maps each DOM element to the type that it is associated with.

### public filter: FilterFunction source

Defines which DOM attributes and elements to filter out. Also filters remote changes.

### public opts: * source

### public typeToDom: Map source

Maps each YXml type to the DOM element that it is associated with.

## Public Methods

### public destroy() source

Remove all properties that are handled by this class.

#### Override:

Binding#destroy

### public enableSmartScrolling(scrollElement: Element) source

Enables the smart scrolling functionality for a Dom Binding. This is useful when YXml is bound to a shared editor. When activated, the viewport will be changed to accommodate remote changes.

#### Params:

Name | Type | Attribute | Description
scrollElement | Element |  | The node that is

### public setFilter(filter: FilterFunction) source

NOTE: currently does not apply filter to existing elements!

#### Params:

Name | Type | Attribute | Description
filter | FilterFunction |  | The filter function to use from now on.