Skip to content

Instantly share code, notes, and snippets.

@njx
Created December 18, 2012 23:56
Show Gist options
  • Save njx/4333230 to your computer and use it in GitHub Desktop.
Save njx/4333230 to your computer and use it in GitHub Desktop.
CodeMirror line widget removal bug
<!doctype html>
<html>
<head>
<title>Widget Removal Bug</title>
<link rel="stylesheet" href="lib/codemirror.css">
<script src="lib/codemirror.js"></script>
<link rel="stylesheet" href="doc/docs.css">
<style type="text/css">
.CodeMirror {border: 1px solid black;}
</style>
</head>
<body>
<h1>Widget Removal Bug</h1>
<div id="editor"></div>
<script id="script">
window.onload = function() {
var content = "";
for (var i = 0; i < 100; i++) {
content += "Line " + i + "\n";
}
window.editor = CodeMirror(document.getElementById("editor"), {
lineNumbers: true,
value: content
});
var node = document.createElement("div");
node.style.backgroundColor = "#666666";
node.style.height = "300px";
window.lineWidget = editor.addLineWidget(1, node);
};
</script>
<input type="button" value="Remove Widget" onclick="editor.removeLineWidget(lineWidget)">
</body>
</html>
@jdgarvey
Copy link

jdgarvey commented Feb 3, 2015

This is about two years later, but you totally saved my butt today. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment