Last active
February 7, 2018 18:29
-
-
Save Aesthetikx/e7b2438f9ed31e269489af9ef9235bc6 to your computer and use it in GitHub Desktop.
Demonstration of embedded script tags influencing stimulus target detection
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<script src="https://unpkg.com/stimulus/dist/stimulus.umd.js"></script> | |
<script> | |
(function() { | |
const application = Stimulus.Application.start() | |
const controller = class extends Stimulus.Controller { | |
connect() { | |
console.log('targets are one and two but not three', this.itemTargets); | |
} | |
}; | |
Stimulus.Controller.targets = ['item']; | |
application.register("hello", controller); | |
})(); | |
</script> | |
<head> | |
<body> | |
<div data-controller="hello"> | |
<div data-target="hello.item">One</div> | |
<div data-target="hello.item">Two</div> | |
<script type="text/javascript">console.log('breaks');</script> | |
<div data-target="hello.item">Three</div> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment