Woes with Template aquisition now resolved with help from Justin, many thanks.
Another couple of issues where behaviour changes between 2.x and 4.2
import stache from ‘can-stache’
import Map from ‘can–map’ (legacy code …)
import Control from can-control
First issue
creating a simple controller barfs if the DOM mount point is not available, eg
const Test = Control.extend({
‘a click’: function($el, ev) {
alert(‘clicked’);
}
new Test(‘div.entry’);
});
if div.entry does not exist you are TOAST and it’s not just the new Test() you need to guard it’s the whole thing. AFAICR this did not happen in 2.x ?? But it is easy to work around …
Second issue
With a working template + controllers etc add a custom tag to the stache template eg but without any supporting code
TOAST again … jQuery Deferred exception node.attibutes is undefined …
this definitely did not happen in 2.x
Surely the custom tag should just render as an empty placeholder ??
Taking a wild guess from renderer code signature in the docs (https://canjs.com/doc/can-stache.renderer.html) perhaps the nodelist should be created as empty if undefined ???
Can I do anything to avoid this ??
Regarding your first issue … This was by design, but we can probably produce a better warning. Creating a control on null almost certainly was a bug, but failing silently didn’t seem be a good idea.
On the second issue, can you give more details about what you are trying? What do you mean by supporting code?
Do you mean you created a custom element like <foo-bar>, but didn’t define it and inserted it into the page via can-stache?