mirror of
https://github.com/anticensority/runet-censorship-bypass.git
synced 2025-10-02 18:06:47 +03:00
Tidy up the html to bypass shadow dom restrictions for form association
This commit is contained in:
parent
aaf9544b61
commit
06813f6c34
|
@ -187,10 +187,10 @@
|
|||
<div>
|
||||
<span id="attributes" hidden>
|
||||
<slot name="id">ID</slot>
|
||||
<slot name="value"></slot>
|
||||
<slot name="value">VALUE</slot>
|
||||
<slot name="for">FOR</slot>
|
||||
</span>
|
||||
<input type="radio" name="pacScript" form="pacChooserForm" data-attrs="id value">
|
||||
<slot name="input">INPUT</slot>
|
||||
<label data-attrs="for">
|
||||
<slot name="label">LABEL</slot>
|
||||
</label>
|
||||
|
@ -205,6 +205,7 @@
|
|||
<span slot="id">antizapret</span>
|
||||
<span slot="value">antizapret</span>
|
||||
<span slot="for">antizapret</span>
|
||||
<input slot="input" attrs-line='type="radio" name="pacScript" form="pacChooserForm"' data-attrs="id value">
|
||||
</pac-record>
|
||||
</li>
|
||||
<li>
|
||||
|
|
|
@ -6,13 +6,13 @@ customElements.define('pac-record',
|
|||
// static observedAttributes = ['data-checked'];
|
||||
constructor() {
|
||||
super();
|
||||
this.internals = this.attachInternals();
|
||||
const shadow = this.attachShadow({ mode: 'open' });
|
||||
// const shadow = this.internals.shadowRoot;
|
||||
console.log('Constructor');
|
||||
const fragment = pacRecordTemplate.content.cloneNode(true);
|
||||
shadow.appendChild(fragment);
|
||||
//const templateAttrs = shadow.querySelectorAll('#attributes > slot[name]');
|
||||
this.internals = this.attachInternals();
|
||||
|
||||
const dataAttrs = shadow.querySelectorAll('*[data-attrs]');
|
||||
dataAttrs.forEach(
|
||||
(da) => {
|
||||
|
@ -21,23 +21,29 @@ customElements.define('pac-record',
|
|||
console.log(shadow.querySelector(`#attributes > slot[name=${attr}]`));
|
||||
da.setAttribute(
|
||||
attr,
|
||||
shadow.querySelector(`#attributes > slot[name=${attr}]`).assignedNodes()?.[0].textContent,
|
||||
shadow.querySelector(`#attributes > slot[name=${attr}]`).assignedNodes()?.[0]?.textContent,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
);
|
||||
//this.internals.setFormValue('');
|
||||
//this.internals.setFormValue('pacScript');
|
||||
//const templateAttrs = shadow.querySelectorAll('#attributes > slot[name]');
|
||||
const namedInputs = shadow.querySelectorAll('input[name]');
|
||||
console.log('NAMED INPUTS:', namedInputs);
|
||||
namedInputs.forEach((ni) => {
|
||||
//this.internals.setFormValue(ni.name);
|
||||
ni.addEventListener('click',
|
||||
ni.addEventListener('input',
|
||||
(event) => {
|
||||
const t = event.target;
|
||||
const entries = new FormData();
|
||||
//entries.set(ni.getAttribute('name'), ni.getAttribute('value'));
|
||||
entries.set('pacScript', 'antizapret');
|
||||
this.internals.setFormValue(t.checked ? t.value : null);
|
||||
ni.toggleAttribute('checked');
|
||||
entries.append('pacScript', t.value);
|
||||
this.internals.setFormValue(entries);
|
||||
//this.value = t.value;
|
||||
//this.internals.setFormValue(t.value);
|
||||
//ni.toggleAttribute('checked');
|
||||
//this.internals.setFormValue(ni.value);
|
||||
//this.toggleAttribute('checked');
|
||||
//this.toggleAttribute('data-checked');
|
||||
|
@ -45,9 +51,9 @@ customElements.define('pac-record',
|
|||
console.log('EVENT TARGET:', event.target);
|
||||
console.log('THIS', this);
|
||||
console.log(this.internals);
|
||||
console.log('EEEE', entries);
|
||||
console.log('EEEE', Array.from(...entries));
|
||||
console.log(`FFFF:${ni.name}=${ni.value}`);
|
||||
return true;
|
||||
ni.click();
|
||||
})
|
||||
});
|
||||
|
||||
|
@ -60,13 +66,12 @@ customElements.define('pac-record',
|
|||
input.id = input.value = label.htmlFor = this.dataset.id;*/
|
||||
|
||||
}
|
||||
/*
|
||||
attributeChangedCallback(name, oldValue, newValue) {
|
||||
console.log('attributeChangedCallback:', oldValue, '->', newValue);
|
||||
const entries = new FormData();
|
||||
entries.set('pacScript', 'antizapret');
|
||||
this.internals.setFormValue(entries);
|
||||
}*/
|
||||
}
|
||||
}
|
||||
);
|
||||
/*
|
||||
|
|
Loading…
Reference in New Issue
Block a user