<!DOCTYPE html>
<html>
<body>
<!--For convenience, this demo uses files from JSDelivr CDN; for more privacy and security download and host them yourself.-->
<script src="https://cdn.jsdelivr.net/gh/WebCoder49/code-input@2.8/code-input.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/WebCoder49/code-input@2.8/code-input.min.css">
<!--Import-->
<script src="https://cdn.jsdelivr.net/gh/WebCoder49/code-input@2.8/plugins/indent.min.js"></script>
<script>
codeInput.registerTemplate("real", new codeInput.Template((elem) => {}, false, false, false, [new codeInput.plugins.Indent()]));
</script>
<button onclick="document.querySelector('code-input').setAttribute('template', 'nonexistent');">Switch to nonexistent template</button>
<button onclick="document.querySelector('code-input').setAttribute('template', 'real');">Switch to real template</button>
<button onclick='codeInput.registerTemplate("nonexistent", new codeInput.Template((elem) => {}, false, false, false, [new codeInput.plugins.Indent()]));'>Register nonexistent template</button>
<code-input style="outline: 2px solid grey;" template="real"><textarea data-code-input-fallback></textarea></code-input>
</body>
</html>
Steps to reproduce
This
code-inputelement is at first properly registered under the "real" template. The "nonexistent" template is initially unregistered.code-inputelement so code-input.js can technically do anything from now on. Nevertheless, we should be kind to the user.)code-inputelement.Expected outcome:
code-inputelement should become usable again, using the newly-registered template called "nonexistent" template. This could be similar to the fallback textarea which would be shown if the "real" template initially held by thecode-inputelement had never been registered.code-inputelement is using an unregistered template.Actual outcome:
code-inputelement breaks enough in response to step 2 that it is still not usable after step 3 (registering the template)code-input's highlighted element stops responding to editing in thetextarea, and a very large number of errors are logged in the console.