Skip to content

Commit 45bcaf4

Browse files
committed
removing data-live-id-value in favor of data-live-id - no need for both
1 parent 3ccf783 commit 45bcaf4

File tree

3 files changed

+4
-10
lines changed

3 files changed

+4
-10
lines changed

src/LiveComponent/assets/src/live_controller.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ export default class extends Controller<HTMLElement> implements LiveController {
5050
readonly csrfValue!: string;
5151
readonly hasDebounceValue: boolean;
5252
readonly debounceValue: number;
53-
readonly idValue: string;
5453
readonly fingerprintValue: string
5554

5655
/** The component, wrapped in the convenience Proxy */
@@ -70,7 +69,7 @@ export default class extends Controller<HTMLElement> implements LiveController {
7069
initialize() {
7170
this.handleDisconnectedChildControllerEvent = this.handleDisconnectedChildControllerEvent.bind(this);
7271

73-
const id = this.idValue || null;
72+
const id = this.element.dataset.liveId || null;
7473

7574
this.component = new Component(
7675
this.element,

src/LiveComponent/assets/src/morphdom.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export function executeMorphdom(
2020
childComponents.forEach((childComponent) => {
2121
childComponentMap.set(childComponent.element, childComponent);
2222
// TODO: add driver to make this agnostic
23-
const childComponentToElement = rootToElement.querySelector(`[data-live-id-value=${childComponent.id}]`)
23+
const childComponentToElement = rootToElement.querySelector(`[data-live-id=${childComponent.id}]`)
2424
if (childComponentToElement && childComponentToElement.tagName !== childComponent.element.tagName) {
2525
// we need to "correct" the tag name for the child to match the "from"
2626
// so that we always get a "diff", not a remove/add
@@ -36,12 +36,7 @@ export function executeMorphdom(
3636
}
3737

3838
// TODO: abstract out to make this function agnostic of markup
39-
if (node.dataset.liveId) {
40-
return node.dataset.liveId;
41-
}
42-
43-
// TODO: do we really need data-live-id and data-live-value-id?
44-
return node.dataset.liveIdValue
39+
return node.dataset.liveId;
4540
},
4641
onBeforeElUpdated: (fromEl, toEl) => {
4742
if (fromEl === rootFromElement) {

src/LiveComponent/assets/test/tools.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ export function initComponent(data: any, props: any = {}, controllerValues: any
441441
data-live-props-value="${dataToJsonAttribute(props)}"
442442
${controllerValues.debounce ? `data-live-debounce-value="${controllerValues.debounce}"` : ''}
443443
${controllerValues.csrf ? `data-live-csrf-value="${controllerValues.csrf}"` : ''}
444-
${controllerValues.id ? `data-live-id-value="${controllerValues.id}"` : ''}
444+
${controllerValues.id ? `data-live-id="${controllerValues.id}"` : ''}
445445
${controllerValues.fingerprint ? `data-live-fingerprint-value="${controllerValues.fingerprint}"` : ''}
446446
`;
447447
}

0 commit comments

Comments
 (0)