2

Why does LockerService Error while using Range.setStart?

Getting the error "Failed to execute 'setStart' on 'Range': parameter 1 is not of type 'Node'.

This is when using popper.js dependency in a LockerService component. This seems to be because Locker Service is passing a Proxy Object rather than the DOM element it is expecting.

Here is the API docs for this: https://developer.mozilla.org/en-US/docs/Web/API/Range/setStart, would expect this fails for setEnd as well.

Looks very similar to the previously reported & fixed issue: Summer 17 LockerService Error while using Node.contains

Relevant code is in https://github.com/FezVrasta/popper.js/blob/master/packages/popper/src/utils/findCommonOffsetParent.js (lines 27-29)

  // Get common ancestor container
  const range = document.createRange();
  range.setStart(start, 0);
  range.setEnd(end, 0);
  const { commonAncestorContainer } = range;

This library is used in React - Lightning Design System (https://react.lightningdesignsystem.com) the official react library that implements the lightning Design System so I believe it is pretty essential this is supported.

7
  • Could you please edit your post to actually ask a question? Additionally, could you add any relevant code? Thanks!
    – Adrian Larson
    Mar 7 '19 at 5:02
  • @AdrianLarson done.
    – Mac Morgan
    Mar 7 '19 at 14:57
  • Please include your code on this site. A good question or answer here does not require a user to navigate elsewhere. Thanks!
    – Adrian Larson
    Mar 7 '19 at 15:22
  • @AdrianLarson added the broken code directly
    – Mac Morgan
    Mar 7 '19 at 16:46
  • Try to change your API version to 39
    – Jeex Box
    Apr 30 '19 at 12:06

Your Answer

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

Browse other questions tagged or ask your own question.