-
Notifications
You must be signed in to change notification settings - Fork 0
feat: client updates for livepage features #10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| 0.7.0 | ||
| 0.7.1 |
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,4 +1,5 @@ | ||||||||||||||||
| import { debounce, throttle } from "../utils/rate-limit"; | ||||||||||||||||
| import { checkLvtConfirm } from "../utils/confirm"; | ||||||||||||||||
| import type { Logger } from "../utils/logger"; | ||||||||||||||||
|
|
||||||||||||||||
| export interface EventDelegationContext { | ||||||||||||||||
|
|
@@ -142,17 +143,10 @@ export class EventDelegator { | |||||||||||||||
| targetElement, | ||||||||||||||||
| }); | ||||||||||||||||
|
|
||||||||||||||||
| if ( | ||||||||||||||||
| action === "delete" && | ||||||||||||||||
| targetElement.hasAttribute("lvt-confirm") | ||||||||||||||||
| ) { | ||||||||||||||||
| const confirmMessage = | ||||||||||||||||
| targetElement.getAttribute("lvt-confirm") || | ||||||||||||||||
| "Are you sure you want to delete this item?"; | ||||||||||||||||
| if (!confirm(confirmMessage)) { | ||||||||||||||||
| this.logger.debug("Delete action cancelled by user"); | ||||||||||||||||
| return; | ||||||||||||||||
| } | ||||||||||||||||
| // Handle lvt-confirm for any action | ||||||||||||||||
| if (!checkLvtConfirm(targetElement as HTMLElement)) { | ||||||||||||||||
|
Comment on lines
+146
to
+147
|
||||||||||||||||
| // Handle lvt-confirm for any action | |
| if (!checkLvtConfirm(targetElement as HTMLElement)) { | |
| // Only apply lvt-confirm to delete-like actions to avoid breaking behavior | |
| const isDeleteAction = | |
| typeof action === "string" && /^delete/i.test(action); | |
| if (isDeleteAction && !checkLvtConfirm(targetElement as HTMLElement)) { |
Copilot
AI
Dec 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The refactored lvt-confirm handling now applies to all actions, not just delete actions. This is a significant behavioral change that should be covered by tests. The existing tests/event-delegation.test.ts does not have any tests for lvt-confirm functionality. Tests should be added to verify that: 1) actions with lvt-confirm are properly blocked when the user cancels, 2) actions proceed when the user confirms, and 3) this works for various action types (not just delete).
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| /** | ||
| * Check if an element has lvt-confirm attribute and prompt user if needed. | ||
| * Returns true if action should proceed, false if cancelled. | ||
| */ | ||
| export function checkLvtConfirm(element: HTMLElement): boolean { | ||
| if (element.hasAttribute("lvt-confirm")) { | ||
| const confirmMessage = element.getAttribute("lvt-confirm"); | ||
| if (confirmMessage && !confirm(confirmMessage)) { | ||
| return false; // User cancelled | ||
| } | ||
| } | ||
| return true; // Proceed | ||
| } | ||
|
Comment on lines
+5
to
+13
|
||
|
|
||
| /** | ||
| * Extract lvt-data-* attributes from an element. | ||
| * lvt-data-id="123" becomes { id: "123" } | ||
| * lvt-data-user-name="john" becomes { "user-name": "john" } | ||
| */ | ||
| export function extractLvtData(element: HTMLElement): Record<string, string> { | ||
| const data: Record<string, string> = {}; | ||
| const attributes = element.attributes; | ||
|
|
||
| for (let i = 0; i < attributes.length; i++) { | ||
| const attr = attributes[i]; | ||
| if (attr.name.startsWith("lvt-data-")) { | ||
| const key = attr.name.substring(9); // Remove "lvt-data-" prefix | ||
| data[key] = attr.value; | ||
| } | ||
| } | ||
|
|
||
| return data; | ||
| } | ||
|
Comment on lines
+20
to
+33
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The CHANGELOG entry for v0.7.1 lists changes from previous PRs (issues #6-9) that don't appear to be related to this PR. According to the PR description, this PR adds client-side updates for livepage features including event delegation updates, livetemplate client updates, and a confirm utility. The CHANGELOG should be updated to accurately reflect the changes in this specific PR.