When I try to create a Range object in ace.js, an Illegal Constructor error occurs

I am trying to create a Range object for ace.js editor in my code, but it does not work. This is unsuccessful, I cannot understand. In the Ace documentation, this constructor:

 new Range(Number startRow, Number startColumn, Number endRow, Number endColumn) 

But when I try this in my code:

 new Range(0, 0, 0, 1) 

It throws an Uncaught TypeError: Illegal constructor error. What causes this behavior and why is it not consistent with the documentation?

+8
javascript ace-editor
source share
2 answers

Range is a native type, it is the majority of browsers that you cannot create. I am not very familiar with Ace, but I assume that they use some kind of namespace so that you do something like new Ace.Range() .

Edit: It looks like they are using CommonJS, so you can import the method and alias as you like:

 var Range = require('ace/range').Range, mine = new Range(0,0,10,0); 
+14
source share

Replace require('ace/range').Range with ace.require('ace/range').Range

+1
source share

All Articles