Skip to content

Instantly share code, notes, and snippets.

@dmrty
Created June 15, 2021 08:02
Show Gist options
  • Save dmrty/0a60b147e8c4e395ab679e655c460aab to your computer and use it in GitHub Desktop.
Save dmrty/0a60b147e8c4e395ab679e655c460aab to your computer and use it in GitHub Desktop.
Bug in Stimulus – moving Controller when initialising
<html>
<head>
<script type="text/javascript" src="https://unpkg.com/stimulus@2.0.0/dist/stimulus.umd.js"></script>
<script type="text/javascript">
(() => {
const application = Stimulus.Application.start()
application.register("hello", class extends Stimulus.Controller {
static get targets() {
return [ "name", "output" ]
}
connect() {
var node = document.createElement("div");
document.body.appendChild(node);
node.appendChild(this.element); // This line makes the browser crash
}
})
})()
</script>
</head>
<body>
<div data-controller="hello">
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment