Sha256: 794000b9871f55f2dddf6272841918a3d2ba853ab44c793a7d6da2df864e0301
Contents?: true
Size: 1.47 KB
Versions: 4
Compression:
Stored size: 1.47 KB
Contents
class Trix.Watchdog.Deserializer constructor: (@document, @snapshot) -> {@tree, @selection} = @snapshot @deserializeTree() @deserializeSelection() deserializeTree: -> @nodes = {} @element = @deserializeNode(@tree) deserializeNode: (serializedNode) -> node = switch serializedNode.name when "#text" @deserializeTextNode(serializedNode) when "#comment" @deserializeComment(serializedNode) else @deserializeElement(serializedNode) @nodes[serializedNode.id] = node node deserializeTextNode: ({value}) -> @document.createTextNode(value) deserializeComment: ({value}) -> @document.createComment(value) deserializeChildren: (serializedNode) -> for child in serializedNode.children ? [] @deserializeNode(child) deserializeElement: (serializedNode) -> node = @document.createElement(serializedNode.name) node.setAttribute(name, value) for name, value of serializedNode.attributes ? {} node.removeChild(node.lastChild) while node.lastChild node.appendChild(childNode) for childNode in @deserializeChildren(serializedNode) node deserializeSelection: -> return unless @selection {start, end} = @selection startContainer = @nodes[start.id] endContainer = @nodes[end.id] @range = @document.createRange() @range.setStart(startContainer, start.offset) @range.setEnd(endContainer, end.offset) @range getElement: -> @element getRange: -> @range
Version data entries
4 entries across 4 versions & 1 rubygems