SShortSingh.
Back to feed

Why dblclick silently fails when a click handler replaces the DOM element

0
·8 views

A web developer discovered that double-click events never fire when a click handler replaces the target DOM element, with no console errors to signal the problem. Testing across Chromium 148, Firefox 150, and WebKit 26.4 confirmed that all three browsers drop the dblclick event if the second click lands on a newly created node rather than the original one. Crucially, the issue is about node identity — removing and reinserting the same object works fine, but swapping in a new node with identical markup does not. The dblclick also does not bubble up to parent elements, so attaching a listener higher in the DOM tree offers no escape. A reliable cross-browser fix is to check the click event's detail property inside the click handler, since detail correctly reaches 2 on the second click regardless of whether the target node was replaced.

Read the full story at DEV Community

This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)

Log in to join the discussion and vote.

Log in

Related stories

0
ProgrammingDEV Community ·

Oracle SQL: Four Built-in JSON Functions That Transform Relational Data

Oracle Database offers four built-in SQL functions — JSON_OBJECT, JSON_OBJECTAGG, JSON_ARRAY, and JSON_ARRAYAGG — to convert relational table data into JSON format directly within SQL queries. JSON_OBJECT and JSON_ARRAY are scalar functions that operate row by row, producing a JSON object or array for each individual record. In contrast, JSON_OBJECTAGG and JSON_ARRAYAGG are aggregate functions that consolidate multiple rows into a single JSON document or array respectively. JSON_ARRAYAGG is particularly useful in API development and reporting, while JSON_OBJECTAGG suits scenarios requiring dynamic serialization of query results for REST APIs or NoSQL migrations. Developers can practice these functions using Oracle's standard EMP table, which contains employee fields such as EMPNO, ENAME, JOB, and SAL.

0
ProgrammingDEV Community ·

Oracle PL/SQL: How Pipelined Table Functions Outperform Regular Ones

Oracle PL/SQL offers two types of table functions — regular and pipelined — both capable of returning collections queryable directly in SQL FROM clauses. Regular table functions load the entire result set into PGA memory before returning data, leading to higher memory usage and slower time-to-first-row, making them suitable mainly for small datasets. Pipelined functions, by contrast, stream rows incrementally to the caller using the PIPE ROW construct, significantly reducing memory overhead and improving responsiveness for large ETL or real-time data operations. A key syntax rule requires that the RETURN statement in a pipelined function remain empty — passing a variable causes a PLS-00633 compilation error. Additionally, the TABLE() wrapper mandatory in Oracle 11g and earlier became optional from Oracle Database 12c Release 2 onward.

0
ProgrammingDEV Community ·

Oracle PL/SQL: Key Differences Between CASE Expression and CASE Statement

In Oracle PL/SQL, the CASE Expression and CASE Statement serve distinct purposes despite sharing similar syntax. A CASE Expression evaluates a condition and returns a single scalar value, making it suitable for assignments or inline SQL use, while a CASE Statement executes one or more procedural actions based on conditions. Their termination syntax also differs: CASE Statements close with END CASE; whereas CASE Expressions end with END. A critical behavioral difference involves unhandled cases — a CASE Statement with no matching WHEN clause and no ELSE raises a runtime ORA-06592 exception, while a CASE Expression silently returns NULL under the same circumstances. Developers should account for these distinctions to avoid unexpected runtime errors in production PL/SQL code.

0
ProgrammingDEV Community ·

Rails gem 'viewing_as' adds read-only, audited admin impersonation with write guards

Delist My Data, a personal data removal service, built a customer account impersonation feature for its admin team that enforces read-only access and maintains a transparent audit log visible to customers. Existing Rails gems like pretender and devise_masquerade handle user-switching but lack write restrictions, session timeouts, or customer-facing audit trails. The team addressed this with two protection layers: a before_action that blocks non-GET/HEAD requests during impersonation, and ActiveRecord's while_preventing_writes to catch any writes that slip through via GET routes. The solution also uses signed cookies to lock session settings like read-only mode so nothing can be altered from the browser mid-session. Last week, the company extracted the feature into an open-source gem called viewing_as for other Rails developers to use.