Skip to content

Improved development warnings, better tag method response

Compare
Choose a tag to compare
@Macrofig Macrofig released this 29 Sep 15:00
· 147 commits to master since this release

Improved Tag response

When attempting to retrieve the handle for a given tag that has not been registered, like tag('hello-world'), the tag method would return a noop. In some cases, this made it difficult to determine if a tag exists or not since a tag that exists returns a function as well.

Now, can-view-callbacks exports a default noop function, defaultCallback so a comparison can be made to the result of the tag method.

import callbacks from 'can-view-callbacks';
const tagHandler = tag('hello-world');
const tagNotRegistered = callbacks.defaultCallback === tagHandler;

Improved development warnings

A custom element attribute must be registered before it is rendered on an element. Previously, rendering an element with a custom attribute would not log a warning. A warning was added with a reminder that the attribute must be defined before it is used.