diff --git a/CHANGELOG.md b/CHANGELOG.md
index af0f8de..6f0a282 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,14 @@
+# 1.2.3
+
+Released on Sunday, November 22 2026.
+
+- Fixed `undefined` for an argument of an enumeration (e.g. the `how` of `compareBoundaryPoints`) throwing an error scripts could not catch
+- Fixed event handler attributes of forms and selects (e.g. `form.onsubmit`) not being set
+- Fixed a frame not finding the functions and variables of a script of another window, e.g. `parent.notify()`
+- Fixed `adoptedStyleSheets` not being an array
+- Added the constants of the interfaces, e.g. `Node.ELEMENT_NODE`, `Range.START_TO_END` or `NodeFilter.SHOW_ELEMENT`
+- Added the callbacks of form-associated custom elements, e.g. `formResetCallback`
+
# 1.2.2
Released on Sunday, November 15 2026.
diff --git a/src/AngleSharp.Js.Docs/package.json b/src/AngleSharp.Js.Docs/package.json
index 5d49256..23c6a67 100644
--- a/src/AngleSharp.Js.Docs/package.json
+++ b/src/AngleSharp.Js.Docs/package.json
@@ -1,6 +1,6 @@
{
"name": "@anglesharp/js",
- "version": "1.2.2",
+ "version": "1.2.3",
"preview": true,
"description": "The doclet for the AngleSharp.Js documentation.",
"keywords": [
diff --git a/src/AngleSharp.Js.Tests/Acid3Tests.cs b/src/AngleSharp.Js.Tests/Acid3Tests.cs
new file mode 100644
index 0000000..70919cd
--- /dev/null
+++ b/src/AngleSharp.Js.Tests/Acid3Tests.cs
@@ -0,0 +1,62 @@
+namespace AngleSharp.Js.Tests
+{
+ using AngleSharp.Dom;
+ using AngleSharp.Html.Dom;
+ using NUnit.Framework;
+ using System.Threading.Tasks;
+
+ ///
+ /// Behavior the Acid3 test (acid3.acidtests.org) relies on.
+ ///
+ [TestFixture]
+ public class Acid3Tests
+ {
+ [Test]
+ public async Task ConstantsAreOnTheInterfacesAndTheirInstances()
+ {
+ var result = await "[Node.ELEMENT_NODE, document.DOCUMENT_FRAGMENT_NODE, document.documentElement.TEXT_NODE, Range.START_TO_END, document.createRange().END_TO_START, Event.CAPTURING_PHASE, NodeFilter.SHOW_ELEMENT].join()".EvalScriptAsync();
+ Assert.AreEqual("1,11,3,1,3,1,1", result);
+ }
+
+ [Test]
+ public async Task ConstantsCannotBeChanged()
+ {
+ var result = await "(function () { Node.ELEMENT_NODE = 5; document.ELEMENT_NODE = 6; return [Node.ELEMENT_NODE, document.ELEMENT_NODE].join(); })()".EvalScriptAsync();
+ Assert.AreEqual("1,1", result);
+ }
+
+ [Test]
+ public async Task UndefinedForAnEnumerationArgumentIsZero()
+ {
+ var result = await "(function () { var r = document.createRange(); return r.compareBoundaryPoints(r.NO_SUCH_CONSTANT, r.cloneRange()); })()".EvalScriptAsync();
+ Assert.AreEqual("0", result);
+ }
+
+ [Test]
+ public async Task EventHandlerOfAFormIsNotANamedProperty()
+ {
+ var result = await "(function () { var f = document.createElement('form'); var n = 0; f.onsubmit = function () { n++; }; f.appendChild(document.createElement('input')); document.documentElement.appendChild(f); f.dispatchEvent(new Event('submit')); return [n, typeof f.onsubmit, f.length, f[0].tagName].join(); })()".EvalScriptAsync();
+ Assert.AreEqual("1,function,1,INPUT", result);
+ }
+
+ [Test]
+ public async Task FrameCallsAFunctionOfItsParent()
+ {
+ var config = Configuration.Default.WithJs().WithEventLoop();
+ var document = await BrowsingContext.New(config).OpenAsync(m => m.Content(@"
"));
+ await document.WhenStable();
+ var frame = (IHtmlInlineFrameElement)document.QuerySelector("iframe");
+ await frame.ContentDocument.WhenStable();
+
+ Assert.AreEqual("function from frame", document.Title);
+ }
+ }
+}
diff --git a/src/AngleSharp.Js.Tests/ObservableArrayTests.cs b/src/AngleSharp.Js.Tests/ObservableArrayTests.cs
new file mode 100644
index 0000000..ce14f00
--- /dev/null
+++ b/src/AngleSharp.Js.Tests/ObservableArrayTests.cs
@@ -0,0 +1,61 @@
+namespace AngleSharp.Js.Tests
+{
+ using AngleSharp.Attributes;
+ using AngleSharp.Dom;
+ using NUnit.Framework;
+ using System;
+ using System.Collections.Generic;
+ using System.Runtime.CompilerServices;
+ using System.Threading.Tasks;
+
+ [DomExposed("Document")]
+ public static class ProbeObservableArrayExtensions
+ {
+ private static readonly ConditionalWeakTable> Lists = new ConditionalWeakTable>();
+
+ public static List Of(IDocument document) => Lists.GetValue(document, _ => new List());
+
+ [DomName("probeElements")]
+ [DomAccessor(Accessors.Getter)]
+ public static IList GetProbeElements(this IDocument document) => Of(document);
+
+ [DomName("probeElements")]
+ [DomAccessor(Accessors.Setter)]
+ public static void SetProbeElements(this IDocument document, IEnumerable elements)
+ {
+ var list = Of(document);
+ list.Clear();
+ list.AddRange(elements);
+ }
+ }
+
+ ///
+ /// A mutable IList of the DOM is a WebIDL ObservableArray (e.g. adoptedStyleSheets): an
+ /// array for scripts, whose changes go to the list.
+ ///
+ [TestFixture]
+ public class ObservableArrayTests
+ {
+ [TestCase("Array.isArray(document.probeElements)", "True")]
+ [TestCase("document.probeElements === document.probeElements", "True")]
+ [TestCase("document.probeElements = document.probeElements.concat([document.body]); document.probeElements[0] === document.body", "True")]
+ [TestCase("document.probeElements.push(document.body, document.head); document.probeElements.pop(); document.probeElements.length", "1")]
+ [TestCase("try { document.probeElements.push(1); 'none' } catch (e) { e.name }", "TypeError")]
+ public async Task MutableListIsAnArray(String script, String expected)
+ {
+ var document = await BrowsingContext.New(Configuration.Default.WithJs().With(new ProbeService())).OpenAsync(m => m.Content(""));
+
+ Assert.AreEqual(expected, document.ExecuteScript(script)?.ToString());
+ }
+
+ [Test]
+ public async Task ChangesOfTheArrayGoToTheList()
+ {
+ var document = await BrowsingContext.New(Configuration.Default.WithJs().With(new ProbeService())).OpenAsync(m => m.Content(""));
+
+ document.ExecuteScript("document.probeElements.push(document.body)");
+
+ Assert.AreEqual(new[] { document.Body }, ProbeObservableArrayExtensions.Of(document));
+ }
+ }
+}
diff --git a/src/AngleSharp.Js/Cache/ConstantCache.cs b/src/AngleSharp.Js/Cache/ConstantCache.cs
new file mode 100644
index 0000000..1532e45
--- /dev/null
+++ b/src/AngleSharp.Js/Cache/ConstantCache.cs
@@ -0,0 +1,98 @@
+namespace AngleSharp.Js.Cache
+{
+ using AngleSharp.Attributes;
+ using System;
+ using System.Collections.Concurrent;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Reflection;
+
+ ///
+ /// The WebIDL constants of the interfaces (e.g. Node.ELEMENT_NODE), which the libraries
+ /// declare as the fields of an enum named like the interface owning them.
+ ///
+ static class ConstantCache
+ {
+ private static readonly ConcurrentDictionary[]>> _constants = new();
+
+ // Enums whose name doesn't say the interface owning their constants (AngleSharp 1.10 names
+ // the document for those of a node, which all nodes have).
+ private static readonly Dictionary _owners = new(StringComparer.Ordinal)
+ {
+ { "AngleSharp.Dom.NodeType", "Node" },
+ { "AngleSharp.Dom.DocumentPositions", "Node" },
+ { "AngleSharp.Dom.DomError", "DOMException" },
+ };
+
+ public static IEnumerable> GetConstants(this IEnumerable libs, String name)
+ {
+ if (name is null)
+ {
+ return [];
+ }
+
+ return libs
+ .Select(m => _constants.GetOrAdd(m, Collect))
+ .SelectMany(m => m.TryGetValue(name, out var constants) ? constants : []);
+ }
+
+ private static IReadOnlyDictionary[]> Collect(Assembly assembly)
+ {
+ var result = new Dictionary>>(StringComparer.Ordinal);
+
+ foreach (var type in GetTypes(assembly))
+ {
+ var info = type.GetTypeInfo();
+
+ if (!info.IsEnum || info.GetCustomAttribute() != null)
+ {
+ continue;
+ }
+
+ var owner = _owners.TryGetValue(type.FullName ?? String.Empty, out var known) ? known :
+ info.GetCustomAttributes().FirstOrDefault()?.OfficialName;
+
+ if (owner is null)
+ {
+ continue;
+ }
+
+ foreach (var field in info.DeclaredFields.Where(m => m.IsLiteral))
+ {
+ var constant = field.GetCustomAttributes().FirstOrDefault()?.OfficialName;
+
+ if (constant is not null && IsConstantName(constant))
+ {
+ if (!result.TryGetValue(owner, out var list))
+ {
+ result[owner] = list = [];
+ }
+
+ if (!list.Any(m => m.Key == constant))
+ {
+ list.Add(new KeyValuePair(constant, Convert.ToDouble(field.GetRawConstantValue())));
+ }
+ }
+ }
+ }
+
+ return result.ToDictionary(m => m.Key, m => m.Value.ToArray(), StringComparer.Ordinal);
+ }
+
+ // constants are all upper case (the members of a string enumeration are not)
+ private static Boolean IsConstantName(String name) =>
+ name.Length > 0 && Char.IsUpper(name[0]) && name.All(c => Char.IsUpper(c) || Char.IsDigit(c) || c == '_');
+
+ private static IEnumerable GetTypes(Assembly assembly)
+ {
+ try
+ {
+ return assembly.ExportedTypes;
+ }
+ catch (Exception)
+ {
+ return [];
+ }
+ }
+ }
+}
diff --git a/src/AngleSharp.Js/Cache/DomShapeCache.cs b/src/AngleSharp.Js/Cache/DomShapeCache.cs
index 27d9604..9371e99 100644
--- a/src/AngleSharp.Js/Cache/DomShapeCache.cs
+++ b/src/AngleSharp.Js/Cache/DomShapeCache.cs
@@ -182,6 +182,15 @@ public DomShape Build(Engine engine)
}
}
+ // The constants are on the prototype as well, so that a node knows them (node.ELEMENT_NODE).
+ foreach (var constant in _libs.Assemblies.GetConstants(_name))
+ {
+ if (!_members.ContainsKey(constant.Key) && !String.Equals(constant.Key, ConstructorName, StringComparison.Ordinal))
+ {
+ builder.Constant(constant.Key, JsNumber.Create(constant.Value), true);
+ }
+ }
+
if (constructor != null)
{
// The attributes an eagerly written constructor had, and still resolved on first
diff --git a/src/AngleSharp.Js/Cache/MethodCache.cs b/src/AngleSharp.Js/Cache/MethodCache.cs
index c364be2..8c05dfe 100644
--- a/src/AngleSharp.Js/Cache/MethodCache.cs
+++ b/src/AngleSharp.Js/Cache/MethodCache.cs
@@ -32,6 +32,7 @@ private MethodDescription(MethodBase method)
ReturnType = method.GetCustomAttribute()?.ReturnType;
TakesWindow = parameters.Length > 0 && parameters[0].ParameterType == typeof(IWindow);
GivenConversion = (method as MethodInfo)?.ReturnType.GetGivenConversion();
+ ObservableElementType = ObservableArrays.GetElementType((method as MethodInfo)?.ReturnType);
HasReceiver = TakesWindow || (method.IsStatic && method.IsDefined(typeof(ExtensionAttribute), false));
TakesParamArray = parameters.Length > 0 &&
parameters[parameters.Length - 1].GetCustomAttribute() != null;
@@ -52,6 +53,11 @@ public static MethodDescription Of(MethodBase method) =>
public Type ReturnType { get; }
+ ///
+ /// Gets the type of the items if the method returns a WebIDL ObservableArray, else null.
+ ///
+ public Type ObservableElementType { get; }
+
public Boolean TakesWindow { get; }
///
diff --git a/src/AngleSharp.Js/Dom/CustomElementHost.cs b/src/AngleSharp.Js/Dom/CustomElementHost.cs
index 472d4a9..3caca6b 100644
--- a/src/AngleSharp.Js/Dom/CustomElementHost.cs
+++ b/src/AngleSharp.Js/Dom/CustomElementHost.cs
@@ -36,7 +36,7 @@ public static JsValue Get(this CustomElementRegistry registry, String name) =>
///
sealed class CustomElementHost : ICustomElementHost
{
- private static readonly String[] CallbackNames = { "connectedCallback", "disconnectedCallback", "adoptedCallback", "attributeChangedCallback" };
+ private static readonly String[] CallbackNames = { "connectedCallback", "disconnectedCallback", "adoptedCallback", "attributeChangedCallback", "formAssociatedCallback", "formResetCallback", "formDisabledCallback", "formStateRestoreCallback" };
private readonly JsScriptingService _service;
diff --git a/src/AngleSharp.Js/Dom/ObservableArrays.cs b/src/AngleSharp.Js/Dom/ObservableArrays.cs
new file mode 100644
index 0000000..db1bca8
--- /dev/null
+++ b/src/AngleSharp.Js/Dom/ObservableArrays.cs
@@ -0,0 +1,131 @@
+namespace AngleSharp.Js
+{
+ using Jint;
+ using Jint.Native;
+ using Jint.Native.Function;
+ using Jint.Runtime.Interop;
+ using Jint.Runtime;
+ using System;
+ using System.Collections;
+ using System.Collections.Generic;
+ using System.Reflection;
+ using System.Runtime.CompilerServices;
+
+ ///
+ /// WebIDL's ObservableArray (e.g. adoptedStyleSheets), a mutable IList<T> in the
+ /// DOM: script sees a real array (concat, spread, push, ...), whose changes go to the list.
+ /// The array is the same object each time; it shows what the list has when it is got.
+ ///
+ sealed class ObservableArrays
+ {
+ private const String ProxyFactory = @"(function (target, sync) {
+ return new Proxy(target, {
+ set: function (t, key, value) { t[key] = value; sync(t); return true; },
+ deleteProperty: function (t, key) { delete t[key]; sync(t); return true; }
+ });
+ })";
+
+ private readonly EngineInstance _engine;
+ private readonly ConditionalWeakTable