How can I check if a riot tag has already been loaded and compiled (in-browser with script tag), in order to avoid doing it again, programmatically.
In other words, what should I use instead of doesTagExist function in my simplified code, below?
if (!doesTagExist('my-tag')) {
riot.compile('/path/to/my-tag', function() {
riot.mount('dom-node', 'my-tag');
});
} else {
riot.mount('dom-node', 'my-tag');
}
had same problem. After bit of research I think you can't get it directly. Implementation is stored inside __TAG_IMPL which is not accessible from outside. You can however access selector for all implemented tags via
riot.util.tags.selectTags()
, which returns comma separated list of selectors i.e.datepicker,[data-is="datepicker"]
.Oneliner for convenience
or depending on your purity inclination
Note, that first version is future-proof, if riot decides to start using single commas in selector.