FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
JavaScriptCoreBrowserObjectModel/Source/Node.swift at master · Envative-OSS/JavaScriptCoreBrowserObjectModel · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
Envative-OSS
/
JavaScriptCoreBrowserObjectModel
Public
forked from
itsjustcon/JavaScriptCoreBrowserObjectModel
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
JavaScriptCoreBrowserObjectModel
/
Source
/
Node.swift
Copy path
More file actions
More file actions
Latest commit
History
History
History
156 lines (136 loc) · 4.78 KB
Breadcrumbs
JavaScriptCoreBrowserObjectModel
/
Source
/
Node.swift
Copy path
File metadata and controls
156 lines (136 loc) · 4.78 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
//
// Node.swift
// JavaScriptCoreBrowserObjectModel
//
// Created by Connor Grady on 5/6/19.
// Copyright © 2019 Connor Grady. All rights reserved.
//
import
Foundation
import
JavaScriptCore
/*
// SPEC: https://developer.mozilla.org/en-US/docs/Web/API/Node
@objc public protocol NodeJSProtocol: JSExport, EventTargetJSProtocol {
var baseURI: String? { get }
var childNodes: [Node] { get }
var firstChild: Node? { get }
var isConnected: Bool { get }
var lastChild: Node? { get }
var nextSibling: Node? { get }
var nodeName: String { get }
var nodeType: UInt8 { get }
var nodeValue: String? { get set }
//var ownerDocument: Document? { get }
var parentNode: Node? { get }
var parentElement: Element? { get }
var previousSibling: Node? { get }
var textContent: String? { get set }
func appendChild(_ child: Node) -> Node
func cloneNode(_ deep: Bool) -> Node
func compareDocumentPosition(_ otherNode: Node) -> UInt8
func contains(_ otherNode: Node) -> Bool
func getRootNode(_ options: JSValue?) -> Node
func hasChildNodes() -> Bool
func insertBefore(_ newNode: Node, _ referenceNode: Node?) -> Node
func isDefaultNamespace(_ namespaceURI: String?) -> Bool
func isEqualNode(_ otherNode: Node) -> Bool
func isSameNode(_ otherNode: Node) -> Bool
func lookupPrefix() -> String?
func lookupNamespaceURI(_ prefix: String?) -> String?
func normalize() -> Void
func removeChild(_ child: Node) -> Node
func replaceChild(_ newChild: Node, _ oldChild: Node) -> Node
}
@objc public class Node: EventTarget, NodeJSProtocol {
public var baseURI: String?
public var childNodes: [Node] = []
public var firstChild: Node?
public var isConnected: Bool {
if let parentNode = self.parentNode {
return parentNode.isConnected
} else {
return false
}
}
public var lastChild: Node? {
return childNodes.last
}
public var nextSibling: Node? {
if let parentNode = self.parentNode {
let myIndex = parentNode.childNodes.firstIndex(of: self)!
guard myIndex < parentNode.childNodes.count-1 else { return nil }
return parentNode.childNodes[myIndex+1]
} else {
return nil
}
}
public var nodeName: String = ""
public var nodeType: UInt8 = 0
public var nodeValue: String?
public var parentNode: Node?
public var previousSibling: Node? {
if let parentNode = self.parentNode {
let myIndex = parentNode.childNodes.firstIndex(of: self)!
guard myIndex > 0 else { return nil }
return parentNode.childNodes[myIndex-1]
} else {
return nil
}
}
public var textContent: String?
public func appendChild(_ child: Node) -> Node {
childNodes.append(child)
return child
}
public func cloneNode(_ deep: Bool) -> Node {
// TODO: implement function
}
public func compareDocumentPosition(_ otherNode: Node) -> UInt8 {
// TODO: implement function
}
public func contains(_ otherNode: Node) -> Bool {
return childNodes.contains(otherNode)
}
public func getRootNode(_ options: JSValue?) -> Node {
// TODO: implement function
}
public func hasChildNodes() -> Bool {
return childNodes.count > 0
}
public func insertBefore(_ newNode: Node, _ referenceNode: Node?) -> Node {
// TODO: implement function
}
public func isDefaultNamespace(_ namespaceURI: String?) -> Bool {
// TODO: implement function
}
public func isEqualNode(_ otherNode: Node) -> Bool {
// TODO: implement function
}
public func isSameNode(_ otherNode: Node) -> Bool {
// TODO: implement function
}
public func lookupPrefix() -> String? {
return nil
}
public func lookupNamespaceURI(_ prefix: String?) -> String? {
// TODO: implement function
}
public func normalize() {
// TODO: implement function
}
public func removeChild(_ child: Node) -> Node {
if let childIndex = childNodes.firstIndex(of: child) {
childNodes.remove(at: childIndex)
}
// NOTE: if child is actually not a child of this node, this method should throw an exception.
return child
}
public func replaceChild(_ newChild: Node, _ oldChild: Node) -> Node {
if let oldChildIndex = childNodes.firstIndex(of: oldChild) {
childNodes.remove(at: oldChildIndex)
childNodes.insert(newChild, at: oldChildIndex)
}
// NOTE: if oldChild is actually not a child of this node, this method should throw an exception.
return oldChild
}
}
*/
Back
|
FazBrowse Home
|
New Git URL