-
-
Notifications
You must be signed in to change notification settings - Fork 179
/
HTMLBaseElement.ts
58 lines (53 loc) · 1.11 KB
/
HTMLBaseElement.ts
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
import HTMLElement from '../html-element/HTMLElement.js';
import * as PropertySymbol from '../../PropertySymbol.js';
/**
* HTML Base Element.
*
* Reference:
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base.
*/
export default class HTMLBaseElement extends HTMLElement {
public cloneNode: (deep?: boolean) => HTMLBaseElement;
/**
* Returns href.
*
* @returns Href.
*/
public get href(): string {
const href = this.getAttribute('href');
if (href !== null) {
return href;
}
return this[PropertySymbol.ownerDocument].location.href;
}
/**
* Sets href.
*
* @param href Href.
*/
public set href(href: string) {
this.setAttribute('href', href);
}
/**
* Returns target.
*
* @returns Target.
*/
public get target(): string {
return this.getAttribute('target') || '';
}
/**
* Sets target.
*
* @param target Target.
*/
public set target(target: string) {
this.setAttribute('target', target);
}
/**
* @override
*/
public override [PropertySymbol.cloneNode](deep = false): HTMLBaseElement {
return <HTMLBaseElement>super[PropertySymbol.cloneNode](deep);
}
}