Unfortunately, the current stable version of Pure JS (version: 2.79) doesn’t allow the "if it exists" element to be displayed?
The following Pure code snippet shows how the error occurs:
if(selector === '.' || ( !selector && attr ) ){ target[0] = dom; }else{ target = plugins.find(dom, selector); } if(!target || target.length === 0){ return error('The node "' + sel + '" was not found in the template:\n' + outerHTML(dom).replace(/\t/g,' ')); }
As you can see, if target not found (one of the libraries, such as jQuery, dojo, etc.), then the specified error is thrown.
The workaround that I use in such situations is as follows:
- I use a template with all the possible elements so that Pure does not produce errors.
- Some elements (e.g. displaying error messages, etc.) are hidden using CSS classes.
- I am changing CSS classes using Pure and JavaScript functions with directives to hide / show elements depending on the input.
source share