| 196 | } |
| 197 | |
| 198 | export class BaseRRDocument extends BaseRRNode implements IRRDocument { |
| 199 | public readonly nodeType: number = NodeType.DOCUMENT_NODE; |
| 200 | public readonly nodeName = '#document' as const; |
| 201 | public readonly compatMode: 'BackCompat' | 'CSS1Compat' = 'CSS1Compat'; |
| 202 | public readonly RRNodeType = RRNodeType.Document; |
| 203 | public textContent: string | null = null; |
| 204 | |
| 205 | // eslint-disable-next-line @typescript-eslint/no-explicit-any |
| 206 | constructor(...args: any[]) { |
| 207 | super(args); |
| 208 | this.ownerDocument = this; |
| 209 | } |
| 210 | |
| 211 | public get documentElement(): IRRElement | null { |
| 212 | return ( |
| 213 | (this.childNodes.find( |
| 214 | (node) => |
| 215 | node.RRNodeType === RRNodeType.Element && |
| 216 | (node as IRRElement).tagName === 'HTML', |
| 217 | ) as IRRElement) || null |
| 218 | ); |
| 219 | } |
| 220 | |
| 221 | public get body(): IRRElement | null { |
| 222 | return ( |
| 223 | (this.documentElement?.childNodes.find( |
| 224 | (node) => |
| 225 | node.RRNodeType === RRNodeType.Element && |
| 226 | (node as IRRElement).tagName === 'BODY', |
| 227 | ) as IRRElement) || null |
| 228 | ); |
| 229 | } |
| 230 | |
| 231 | public get head(): IRRElement | null { |
| 232 | return ( |
| 233 | (this.documentElement?.childNodes.find( |
| 234 | (node) => |
| 235 | node.RRNodeType === RRNodeType.Element && |
| 236 | (node as IRRElement).tagName === 'HEAD', |
| 237 | ) as IRRElement) || null |
| 238 | ); |
| 239 | } |
| 240 | |
| 241 | public get implementation(): IRRDocument { |
| 242 | return this; |
| 243 | } |
| 244 | |
| 245 | public get firstElementChild(): IRRElement | null { |
| 246 | return this.documentElement; |
| 247 | } |
| 248 | |
| 249 | public appendChild(newChild: IRRNode): IRRNode { |
| 250 | const nodeType = newChild.RRNodeType; |
| 251 | if ( |
| 252 | nodeType === RRNodeType.Element || |
| 253 | nodeType === RRNodeType.DocumentType |
| 254 | ) { |
| 255 | if (this.childNodes.some((s) => s.RRNodeType === nodeType)) { |
nothing calls this directly
no outgoing calls
no test coverage detected