-
-
Notifications
You must be signed in to change notification settings - Fork 106
Expand file tree
/
Copy pathXMLProcessingInstruction.coffee
More file actions
44 lines (32 loc) · 1.24 KB
/
XMLProcessingInstruction.coffee
File metadata and controls
44 lines (32 loc) · 1.24 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
44
NodeType = require './NodeType'
XMLCharacterData = require './XMLCharacterData'
# Represents a processing instruction
module.exports = class XMLProcessingInstruction extends XMLCharacterData
# Initializes a new instance of `XMLProcessingInstruction`
#
# `parent` the parent node
# `target` instruction target
# `value` instruction value
constructor: (parent, target, value) ->
super parent
if not target?
throw new Error "Missing instruction target. " + @debugInfo()
@type = NodeType.ProcessingInstruction
@target = @stringify.insTarget target
@name = @target
@value = @stringify.insValue value if value
# Creates and returns a deep clone of `this`
clone: () ->
Object.create @
# Converts the XML fragment to string
#
# `options.pretty` pretty prints the result
# `options.indent` indentation for pretty print
# `options.offset` how many indentations to add to every line for pretty print
# `options.newline` newline sequence for pretty print
toString: (options) ->
@options.writer.processingInstruction @, @options.writer.filterOptions(options)
isEqualNode: (node) ->
if not super.isEqualNode(node) then return false
if node.target isnt @target then return false
return true