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.

  • 5
    Thanks for the detailed repro steps and investigation. I've verified this is, in fact, a real issue and am working on a fix now. I'll update with an answer as progress is made. Apr 19, 2017 at 22:25
  • Any news @TrevorBliss? This is blocking my LockerService release. Apr 24, 2017 at 20:30
  • 2
    On track for the .3 patch. I only fixed this for 4 of the native Node APIs though. If you see the issue anywhere besides contains, compareDocumentPosition, isEqualNode, or isSameNode, please let us know. Apr 24, 2017 at 22:27
  • @TrevorBliss I still have problems with Node.appendChild (by using jQuery appendTo() method). Still, it calls some native code, still on the Node object and still we have a proxy instead of a Node instance, and still instanceOf Node returns true. May 4, 2017 at 15:01
  • @TrevorBliss do you have any news? Jun 2, 2017 at 20:36

1 Answer 1


This specific issue for Node.contains() and a few other Node APIs are currently scheduled to be fixed in the .3 patch. Of course, this can be delayed if any issues are found with the fix but things are looking on track so far.

Thanks again for detailed bug report and initial debugging.

  • Any word on fixes to Range.setStart()?
    – kamezaburo
    Jan 8, 2021 at 18:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.