Skip to content

Commit 0b6a979

Browse files
committed
Log on lack of Reaction scope in debug
Flag Range.cloneContents as CEReactions setAttributeNode triggers single reaction, rather than a remove + add.
1 parent 3ec443c commit 0b6a979

3 files changed

Lines changed: 7 additions & 3 deletions

File tree

src/browser/CustomElementReactions.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ fn route(self: *Self, frame: *Frame, reaction: Reaction) !void {
9797
return;
9898
}
9999
if (comptime IS_DEBUG) {
100-
lp.log.err(.bug, "custom element scope", .{.note = "Missing explicit reaction scope, using fallback. This log is only generated in debug builds."});
100+
lp.log.err(.bug, "custom element scope", .{ .note = "Missing explicit reaction scope, using fallback. This log is only generated in debug builds." });
101101
}
102102
try self.backup_queue.append(self.allocator, reaction);
103103
if (!self.backup_scheduled) {

src/browser/webapi/Range.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,7 @@ pub const JsApi = struct {
720720
pub const cloneRange = bridge.function(Range.cloneRange, .{ .dom_exception = true });
721721
pub const insertNode = bridge.function(Range.insertNode, .{ .dom_exception = true, .ce_reactions = true });
722722
pub const deleteContents = bridge.function(Range.deleteContents, .{ .dom_exception = true, .ce_reactions = true });
723-
pub const cloneContents = bridge.function(Range.cloneContents, .{ .dom_exception = true });
723+
pub const cloneContents = bridge.function(Range.cloneContents, .{ .dom_exception = true, .ce_reactions = true });
724724
pub const extractContents = bridge.function(Range.extractContents, .{ .dom_exception = true, .ce_reactions = true });
725725
pub const surroundContents = bridge.function(Range.surroundContents, .{ .dom_exception = true, .ce_reactions = true });
726726
pub const createContextualFragment = bridge.function(Range.createContextualFragment, .{ .dom_exception = true, .ce_reactions = true });

src/browser/webapi/element/Attribute.zig

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,11 @@ pub const List = struct {
255255

256256
const existing_attribute = try self.getAttribute(attribute._name, element, frame);
257257
if (existing_attribute) |ea| {
258-
try self.delete(ea._name, element, frame);
258+
// Per DOM "replace an attribute": one handle-attribute-changes call
259+
// with (old, new), not a remove-then-add that would fire two
260+
// attributeChanged reactions. Detach the old wrapper; put() updates
261+
// the entry in place and fires the single reaction.
262+
ea._element = null;
259263
}
260264

261265
const entry = try self.put(attribute._name, attribute._value, element, frame);

0 commit comments

Comments
 (0)