Getting Codemirror internal error: Cannot read property 'splice' of undefined


#1

Hi,

I have installed the latest version 5.25.2, and in the process of integrating it with my application frontend (html, javascript, jquery).

I have installed the files/directories (except for ‘test’) under ‘/codemirror’.

In index.html, I have (re codemirror) (initial < character changed to [):
[link rel=“stylesheet” href="/codemirror/lib/codemirror.css">
[script src="/codemirror/lib/codemirror.js">
[script src="/codemirror/addon/edit/matchbrackets.js">
[script src="/codemirror/mode/python/python.js">

Before getting to any of my application code, it gets the error:
“Cannot read property ‘splice’ of undefined”

Chrome Devtools says:
VM5406 built-editor.min.js:396 Uncaught TypeError: Cannot read property ‘splice’ of undefined
at define (VM5406 built-editor.min.js:396)
at userAgent (VM5434 codemirror.js:12)
at VM5434 codemirror.js:14

VM5434 codemirror.js around lines 12 - 14 show:
(function (global, factory) {
typeof exports === ‘object’ && typeof module !== ‘undefined’ ? module.exports = factory() :
typeof define === ‘function’ && define.amd ? define(factory) :
(global.CodeMirror = factory());
}(this, (function () { ‘use strict’;

I hope I have given enough information above. This looks like it is an issue related to integration with my application, because running a test standalone worked beautifully.

Regards

Colin Goldberg


#2

This probably happens because you’re passing something of the wrong value somewhere, but without a more precise location (line 396 in minified code could be anything), I can’t really say more.


#3

Thanks for your quick response. How can we move forward, so that I can use Codemirror - a great tool. Would it be possible to get hold of an unminified copy just so that I could give you a more precise location?

As I mentioned before, this error is evident before it even executes any of my application code - ie. I am not yet passing any values to codemirror.

I am not sure where built-editor.min.js lives - I could not find it on my first pass…

DevTools does show me the file - I have pasted the first lines below, including copyright notices from IBM. So perhaps this is not even codemirror code! Maybe something to do with ‘require’, or ‘define’ etc (???)

/*

Copyright © 2014 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).

Contributors:
IBM Corporation - initial API and implementation

Copyright © 2013 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).

Contributors: IBM Corporation - initial API and implementation

Copyright © 2010, 2012 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).

Contributors: IBM Corporation - initial API and implementation

Copyright © 2012 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).

Contributors:
Felipe Heidrich (IBM Corporation) - initial API and implementation
Silenio Quarti (IBM Corporation) - initial API and implementation

Copyright © 2010, 2012 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).

Contributors:
Felipe Heidrich (IBM Corporation) - initial API and implementation
Silenio Quarti (IBM Corporation) - initial API and implementation

Copyright © 2012 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).

Contributors: IBM Corporation - initial API and implementation

Copyright © 2010, 2012 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).

Contributors:
Felipe Heidrich (IBM Corporation) - initial API and implementation
Silenio Quarti (IBM Corporation) - initial API and implementation

Copyright © 2010, 2013 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).

Contributors:
Felipe Heidrich (IBM Corporation) - initial API and implementation
Silenio Quarti (IBM Corporation) - initial API and implementation

Copyright © 2013 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).

Contributors:
IBM Corporation - initial API and implementation

Copyright © 2013,2014 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).

Contributors:
IBM Corporation - initial API and implementation

Copyright © 2013 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).

Contributors: IBM Corporation - initial API and implementation

Copyright © 2010, 2014 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).

Contributors:
Felipe Heidrich (IBM Corporation) - initial API and implementation
Silenio Quarti (IBM Corporation) - initial API and implementation
Mihai Sucan (Mozilla Foundation) - fix for Bug#334583 Bug#348471 Bug#349485 Bug#350595 Bug#360726 Bug#361180 Bug#362835 Bug#362428 Bug#362286 Bug#354270 Bug#361474 Bug#363945 Bug#366312 Bug#370584

Copyright © 2010, 2012 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).

Contributors:
Felipe Heidrich (IBM Corporation) - initial API and implementation
Silenio Quarti (IBM Corporation) - initial API and implementation

Copyright © 2010, 2012 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).

Contributors:
Felipe Heidrich (IBM Corporation) - initial API and implementation
Silenio Quarti (IBM Corporation) - initial API and implementation

Copyright © 2010, 2014 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).

Contributors: IBM Corporation - initial API and implementation

Copyright © 2013 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).

Contributors: IBM Corporation - initial API and implementation

Copyright © 2010, 2012 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).

Contributors: IBM Corporation - initial API and implementation

Copyright © 2010, 2012 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).

Contributors: IBM Corporation - initial API and implementation

Copyright © 2010, 2012 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).

Contributors:
Felipe Heidrich (IBM Corporation) - initial API and implementation
Silenio Quarti (IBM Corporation) - initial API and implementation

Copyright © 2009, 2014 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).

Contributors: IBM Corporation - initial API and implementation

Copyright © 2013 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).

Contributors:
IBM Corporation - initial API and implementation

Copyright © 2014 IBM Corporation and others. All rights reserved.
This program and the accompanying materials are made available under the
terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).

Contributors:
IBM Corporation - initial API and implementation

Copyright © 2013 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).

Contributors:
IBM Corporation - initial API and implementation

Copyright © 2010, 2014 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).

Contributors: IBM Corporation - initial API and implementation

Copyright © 2013 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).

Contributors:
IBM Corporation - initial API and implementation

Copyright © 2013 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).

Contributors:
IBM Corporation - initial API and implementation

Copyright © 2011, 2013 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).

Contributors:
IBM Corporation - initial API and implementation

Copyright © 2012 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).

Contributors: IBM Corporation - initial API and implementation

Copyright © 2012 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).

Contributors: IBM Corporation - initial API and implementation

Copyright © 2011, 2014 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).

Contributors:
IBM Corporation - initial API and implementation

Copyright © 2014 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).

Contributors: IBM Corporation - initial API and implementation

Copyright © 2014 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).

Contributors: IBM Corporation - initial API and implementation

Copyright © 2011, 2014 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).

Contributors:
IBM Corporation - initial API and implementation

Copyright © 2011, 2014 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).

Contributors:
IBM Corporation - initial API and implementation

Copyright © 2011, 2012 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).

Contributors: IBM Corporation - initial API and implementation

Copyright © 2011, 2013 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).

Contributors:
IBM Corporation - initial API and implementation

Copyright © 2011, 2012 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).

Contributors: IBM Corporation - initial API and implementation

Copyright © 2011, 2014 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).

Contributors: IBM Corporation - initial API and implementation

Copyright © 2010, 2012 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).

Contributors: IBM Corporation - initial API and implementation
Alex Lakatos - fix for bug#369781

Copyright © 2014 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).

Contributors: IBM Corporation - initial API and implementation

Copyright © 2014 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).

Contributors: IBM Corporation - initial API and implementation

Copyright © 2014 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).

Contributors: IBM Corporation - initial API and implementation

Copyright © 2013 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).

Contributors:
IBM Corporation - initial API and implementation
RequireJS i18n 2.0.2 Copyright © 2010-2012, The Dojo Foundation All Rights Reserved.
Available via the MIT or new BSD license.
see: http://github.com/requirejs/i18n for details

Copyright © 2011, 2013 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).

Contributors:
IBM Corporation - initial API and implementation
/
var requirejs,require,define;
(function§{function t(a,b){var c,l,m,w,n,f,d,s,g,h=b&&b.split("/"),u=e.map,q=u&&u["
"]||{};if(a&&"."===a.charAt(0))if(b){h=h.slice(0,h.length-1);a=h.concat(a.split("/"));for(s=0;s<a.length;s+=1)if(c=a[s],"."===c)a.splice(s,1),s-=1;else if("…"===c)if(1===s&&("…"===a[2]||"…"===a[0]))break;else 0<s&&(a.splice(s-1,2),s-=2);a=a.join("/")}else 0===a.indexOf("./")&&(a=a.substring(2));if((h||q)&&u){c=a.split("/");for(s=c.length;0<s;s-=1){l=c.slice(0,s).join("/");if(h)for(g=h.length;0<g;g-=1)if(m=u[h.slice(0,
g).join("/")])if(m=m[l]){w=m;n=s;break}if(w)break;!f&&(q&&q[l])&&(f=q[l],d=s)}!w&&f&&(w=f,n=d);w&&(c.splice(0,n,w),a=c.join("/"))}return a}function r(a,b){return function(){return c.apply(p,x.call(arguments,0).concat([a,b]))}}function k(a){return function(b){return t(b,a)}}function g(a){return function(b){l[a]=b}}function h(a){if(u.call(n,a)){var b=n[a];delete n[a];s[a]=!0;d.apply(p,b)}if(!u.call(l,a)&&!u.call(s,a))throw Error(“No “+a);return l[a]}function f(a){var b,e=a?a.indexOf(”!”):-1;-1<e&&(b=
a.substring(0,e),a=a.substring(e+1,a.length));return[b,a]}function q(a){return function(){return e&&e.config&&e.config[a]||{}}}var d,c,a,b,l={},n={},e={},s={},u=Object.prototype.hasOwnProperty,x=[].slice;a=function(a,b){var e,c=f(a),m=c[0];a=c[1];m&&(m=t(m,b),e=h(m));m?a=e&&e.normalize?e.normalize(a,k(b)):t(a,b):(a=t(a,b),c=f(a),m=c[0],a=c[1],m&&(e=h(m)));return{f:m?m+"!"+a:a,n:a,pr:m,p:e}};b={require:function(a){return r(a)},exports:function(a){var b=l[a];return"undefined"!==typeof b?b:l[a]={}},
module:function(a){return{id:a,uri:"",exports:l[a],config:q(a)}}};d=function(e,c,f,d){var m,w,B,A,D=[],q;d=d||e;if(“function”===typeof f){c=!c.length&&f.length?[“require”,“exports”,“module”]:c;for(A=0;A<c.length;A+=1)if(B=a(c[A],d),w=B.f,“require”===w)D[A]=b.require(e);else if(“exports”===w)D[A]=b.exports(e),q=!0;else if(“module”===w)m=D[A]=b.module(e);else if(u.call(l,w)||u.call(n,w)||u.call(s,w))D[A]=h(w);else if(B.p)B.p.load(B.n,r(d,!0),g(w),{}),D[A]=l[w];else throw Error(e+" missing "+w);c=f.apply(l[e],
D);if(e)if(m&&m.exports!==p&&m.exports!==l[e])l[e]=m.exports;else if(c!==p||!q)l[e]=c}else e&&(l[e]=f)};requirejs=require=c=function(l,n,f,s,m){if(“string”===typeof l)return b[l]?bl:h(a(l,n).f);l.splice||(e=l,n.splice?(l=n,n=f,f=null):l=p);n=n||function(){};“function”===typeof f&&(f=s,s=m);s?d(p,l,n,f):setTimeout(function(){d(p,l,n,f)},4);return c};c.config=function(a){e=a;return c};define=function(a,b,e){b.splice||(e=b,b=[]);!u.call(l,a)&&!u.call(n,a)&&(n[a]=[a,b,e])};define.amd={jQuery:!0}})();
define(“almond”,function(){});define(“orion/editor/config”,[],function(){return{languages:{}}});

I used jsbeautifier to see the file, and I see references to orion editor. I will continue looking but perhaps there is a name conflict here. I could probably remove orion and see if that makes a difference.

Colin Goldberg


#4

Hi,

The problem was a conflict with the orion editor. With orion removed, it now works as expected.

(Now how do we protect ourselves against name conflicts like this?)

Colin Goldberg