-
-
Notifications
You must be signed in to change notification settings - Fork 106
Expand file tree
/
Copy pathXMLCharacterData.coffee
More file actions
43 lines (30 loc) · 1.31 KB
/
XMLCharacterData.coffee
File metadata and controls
43 lines (30 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
XMLNode = require './XMLNode'
# Represents a character data node
module.exports = class XMLCharacterData extends XMLNode
# Initializes a new instance of `XMLCharacterData`
#
constructor: (parent) ->
super parent
@value = ''
# DOM level 1
Object.defineProperty @::, 'data',
get: () -> @value
set: (value) -> @value = value or ''
Object.defineProperty @::, 'length', get: () -> @value.length
# DOM level 3
Object.defineProperty @::, 'textContent',
get: () -> @value
set: (value) -> @value = value or ''
# Creates and returns a deep clone of `this`
clone: () ->
Object.create @
# DOM level 1 functions to be implemented later
substringData: (offset, count) -> throw new Error "This DOM method is not implemented." + @debugInfo()
appendData: (arg) -> throw new Error "This DOM method is not implemented." + @debugInfo()
insertData: (offset, arg) -> throw new Error "This DOM method is not implemented." + @debugInfo()
deleteData: (offset, count) -> throw new Error "This DOM method is not implemented." + @debugInfo()
replaceData: (offset, count, arg) -> throw new Error "This DOM method is not implemented." + @debugInfo()
isEqualNode: (node) ->
if not super.isEqualNode(node) then return false
if node.data isnt @data then return false
return true