diff --git a/src/AngleSharp.Js.Tests/DomTests.cs b/src/AngleSharp.Js.Tests/DomTests.cs
new file mode 100644
index 0000000..5d1b975
--- /dev/null
+++ b/src/AngleSharp.Js.Tests/DomTests.cs
@@ -0,0 +1,30 @@
+namespace AngleSharp.Js.Tests
+{
+ using NUnit.Framework;
+ using System.Threading.Tasks;
+
+ [TestFixture]
+ public class DomTests
+ {
+ [Test]
+ public async Task NodeHasChildNodesIsAFunction()
+ {
+ var result = await "document.createElement('div').hasChildNodes".EvalScriptAsync();
+ Assert.AreEqual("function hasChildNodes() { [native code] }", result);
+ }
+
+ [Test]
+ public async Task NodeHasChildNodesWithoutChildren()
+ {
+ var result = await "document.createElement('div').hasChildNodes()".EvalScriptAsync();
+ Assert.AreEqual("False", result);
+ }
+
+ [Test]
+ public async Task NodeHasChildNodesWithChildren()
+ {
+ var result = await "new DOMParser().parseFromString(`
`, 'text/html').body.firstChild.hasChildNodes()".EvalScriptAsync();
+ Assert.AreEqual("True", result);
+ }
+ }
+}
diff --git a/src/AngleSharp.Js/Extensions/Extensibility.cs b/src/AngleSharp.Js/Extensions/Extensibility.cs
index 97c9d06..970c562 100644
--- a/src/AngleSharp.Js/Extensions/Extensibility.cs
+++ b/src/AngleSharp.Js/Extensions/Extensibility.cs
@@ -49,6 +49,9 @@ public static IDictionary GetExtensions(this IEnumerable
case Accessors.Adder:
entry.Adder = method;
break;
+ case Accessors.Method:
+ entry.Other = method;
+ break;
}
}
else
diff --git a/src/AngleSharp.Js/Proxies/DomPrototypeInstance.cs b/src/AngleSharp.Js/Proxies/DomPrototypeInstance.cs
index a6d2fd1..df226b9 100644
--- a/src/AngleSharp.Js/Proxies/DomPrototypeInstance.cs
+++ b/src/AngleSharp.Js/Proxies/DomPrototypeInstance.cs
@@ -148,14 +148,32 @@ private void SetNormalProperties(IEnumerable properties)
foreach (var property in properties)
{
var indexParameters = property.GetIndexParameters();
- var index = property.GetCustomAttribute();
+ var accessor = property.GetCustomAttribute()?.Type;
var putsForward = property.GetCustomAttribute();
var names = property
.GetCustomAttributes()
.Select(m => m.OfficialName)
.ToArray();
- if (index != null || Array.Exists(names, m => m.Is("item")))
+ if (accessor == Accessors.Method)
+ {
+ // property decorated with Method accessor, so we need to treat it as a method, not a property
+
+ if (property.GetMethod == null)
+ {
+ throw new InvalidOperationException("Getter not found.");
+ }
+
+ foreach (var name in names)
+ {
+ SetMethod(name, property.GetMethod);
+ }
+
+ // methods were set, so finish processing
+ return;
+ }
+
+ if (accessor == Accessors.Getter || accessor == Accessors.Setter || Array.Exists(names, m => m.Is("item")))
{
SetIndexer(property, indexParameters);
}