When I try to execute the following code:
this.root.contains(this.element)
where root is a "SecureElement: [object HTMLDivElement]{ key: {"namespace":"xyz"} }"
and element is a "SecureElement: [object HTMLDivElement]{ key: {"namespace":"xyz"} }"
, I get this error:
TypeError: Failed to execute 'contains' on 'Node': parameter 1 is not of type 'Node'. at Proxy.value
The error comes from SecureObject.$createFilteredMethodStateless$
on the var fnReturnedValue = raw[methodName].apply(raw, filteredArgs);
line. In the filteredArgs
, LockerService passes a Proxy
object instead of the actual HTMLDivElement element. When I check filteredArgs[0] instanceof Node
it really returns true
.
This probably happens because the contains
method uses native code. Here's the Mozilla documentation about it: https://developer.mozilla.org/en/docs/Web/API/Node/contains
Who can fix this?
Edit: it seems like all the Node
native methods have the same issue.
Node
APIs though. If you see the issue anywhere besidescontains
,compareDocumentPosition
,isEqualNode
, orisSameNode
, please let us know.appendTo()
method). Still, it calls some native code, still on theNode
object and still we have a proxy instead of a Node instance, and stillinstanceOf Node
returnstrue
.