MCPcopy Create free account
hub / github.com/adearriba/ShopifyCheckoutJS / SelectionMethod

Class SelectionMethod

src/Methods/SelectionMethod.js:3–59  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1import {NotImplementedError} from '../Exceptions/NotImplementedError.js';
2
3export class SelectionMethod extends HTMLDivElement{
4
5 constructor(element){
6 if(!(element instanceof HTMLDivElement)
7 || !element.classList.contains('radio-wrapper')){
8 throw TypeError('Not a radio-wrapper');
9 }
10
11 Object.setPrototypeOf(element, SelectionMethod.prototype);
12 return Object.assign(element, {
13 type: 'generic'
14 });
15 }
16
17 /**
18 * Add a `text` decription to the selection method
19 * @param {string} text
20 */
21 // eslint-disable-next-line no-unused-vars
22 addDescription(text){
23 throw new NotImplementedError();
24 }
25
26 get input(){
27 let input = this.querySelector('input');
28 if(!input) return Error(`No input found for the ${this.type} method`);
29 return input;
30 }
31
32 get label(){
33 return this.querySelector('.radio__label').textContent;
34 }
35
36 get methodData(){
37 return this.input.dataset;
38 }
39
40 get methodId(){
41 return this.input.id;
42 }
43
44 get checked(){
45 return this.input.checked;
46 }
47
48 set checked(boolean){
49 this.input.checked = boolean;
50 }
51
52 /**
53 * Remove the selection method
54 */
55 remove()
56 {
57 this.parentElement.remove()
58 }
59}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected