Make your own tagging system from scratch
kequc.com
kequc.com
I'd like to advocate for minimising this as JavaScript isn't so archaic as it once was in it's past. By using ES6 or TypeScript, building fully customised modules of one's own isn't the chore they're built up to be.
This tagging script took one full day of programming to finish, including the first draft of the blog post about it. Since then I've done things like added the `clearValue` function, rather than being explicit as to what I wanted to happen in every case that it is used. At that point I thought I better post it before I mess with it too much.
I do understand the need/popularity of libraries like jQuery however; In development teams there aren't always dedicated people for 'just' the back-end or 'just' the front-end. Most people do both in varying levels of competency, a library like jQuery makes it a lot easier for people less at home in the front-end to create things. 'Easiers' because of the cross-browser compatibility, consistency and the fast amount of online resources. So I do get it, while it is still not that hard to pick up some new things.
If you are in the front-end a lot/only then sticking to gigantic frameworks without using more modern javascript is just a shame, because it can bring you great benefit.
interface ISuggestion {
name: string;
count: number;
element?: HTMLElement;
type?: string;
} if (this.parts.suggestions && (e.which || e.charCode || e.keyCode) == 9) {
let foo = this.parts.suggestions.children.item(0);
if (foo) foo.click();
}The code looks fine to me, c.f.:
$ node
> undefined || undefined || 4
4
> undefined || 9 || 4
9
The || operator evaluates to the first of its two operands if it is truthy, or its second operand otherwise > undefined || false
false
> false || undefined
undefined
So: > e = {keyCode:9}
> e.which || e.charCode || e.keyCode
9> It's refreshing to build systems like this yourself, as it puts the destiny of your product wholly into your own hands. Instead of falling at the mercy of the developer who made your plugin or extension.
It does however place you on a long path of rediscovering all of the things which don't work (one bug at a time, in various browsers of varying ages) which someone else may have done already.