<!DOCTYPE html><html><body><!--For convenience, this demo uses files from JSDelivr CDN; for more privacy and security download and host them yourself.--><scriptsrc="https://cdn.jsdelivr.net/gh/WebCoder49/code-input@2.8/code-input.min.js"></script><linkrel="stylesheet" href="https://cdn.jsdelivr.net/gh/WebCoder49/code-input@2.8/code-input.min.css"><!--Import--><scriptsrc="https://cdn.jsdelivr.net/gh/WebCoder49/code-input@2.8/plugins/indent.min.js"></script><script>codeInput.registerTemplate("real",newcodeInput.Template((elem)=>{},false,false,false,[newcodeInput.plugins.Indent()]));</script><buttononclick="document.querySelector('code-input').setAttribute('template', 'nonexistent');">Switch to nonexistent template</button><buttononclick="document.querySelector('code-input').setAttribute('template', 'real');">Switch to real template</button><buttononclick='codeInput.registerTemplate("nonexistent", new codeInput.Template((elem) => {}, false, false, false, [new codeInput.plugins.Indent()]));'>Register nonexistent template</button><code-inputstyle="outline: 2px solid grey;" template="real"><textareadata-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.