mirror of
https://github.com/LuanRT/YouTube.js.git
synced 2026-06-13 01:22:11 +00:00
feat(parser): Update Button (#857)
* Add `style` property * Add `size` property * Add `target_id` property * Parse `data.accessibilityData.accessibilityData.label` if `data.accessibility.label` is unavailable
This commit is contained in:
@@ -9,8 +9,11 @@ export default class Button extends YTNode {
|
||||
text?: string;
|
||||
label?: string;
|
||||
tooltip?: string;
|
||||
style?: string;
|
||||
size?: string;
|
||||
icon_type?: string;
|
||||
is_disabled?: boolean;
|
||||
target_id?: string;
|
||||
endpoint: NavigationEndpoint;
|
||||
|
||||
constructor(data: RawNode) {
|
||||
@@ -18,18 +21,34 @@ export default class Button extends YTNode {
|
||||
if (Reflect.has(data, 'text'))
|
||||
this.text = new Text(data.text).toString();
|
||||
|
||||
if (Reflect.has(data, 'accessibility') && Reflect.has(data.accessibility, 'label'))
|
||||
if (Reflect.has(data, 'accessibility') && Reflect.has(data.accessibility, 'label')) {
|
||||
this.label = data.accessibility.label;
|
||||
} else if (
|
||||
Reflect.has(data, 'accessibilityData') &&
|
||||
Reflect.has(data.accessibilityData, 'accessibilityData') &&
|
||||
Reflect.has(data.accessibilityData.accessibilityData, 'label')
|
||||
) {
|
||||
this.label = data.accessibilityData.accessibilityData.label;
|
||||
}
|
||||
|
||||
if (Reflect.has(data, 'tooltip'))
|
||||
this.tooltip = data.tooltip;
|
||||
|
||||
if (Reflect.has(data, 'style'))
|
||||
this.style = data.style;
|
||||
|
||||
if (Reflect.has(data, 'size'))
|
||||
this.size = data.size;
|
||||
|
||||
if (Reflect.has(data, 'icon') && Reflect.has(data.icon, 'iconType'))
|
||||
this.icon_type = data.icon.iconType;
|
||||
|
||||
if (Reflect.has(data, 'isDisabled'))
|
||||
this.is_disabled = data.isDisabled;
|
||||
|
||||
if (Reflect.has(data, 'targetId'))
|
||||
this.target_id = data.targetId;
|
||||
|
||||
this.endpoint = new NavigationEndpoint(data.navigationEndpoint || data.serviceEndpoint || data.command);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user