The Problem with Learning by Doing: DOM events

Sometimes you learn wrong.

I’ve built myself a little music player that loops sections of songs pretty much as long as one could want. I’m asking the user to pick a minimum duration from 0 seconds to 1 day. This creates an interesting UI problem: the user probably wants to pick something in the realm of 5 minutes, but 5 minutes is only 1 pixel away from 10 minutes on this scale. So I wrote a script that will get and set the value of a range input logarithmically, so that the left 1/3 covers 10 minutes, the middle 1/3 covers 5 hours, and the right 1/3 covers 1 day. This works great, and the user has fine control within each unit scale.

This creates a further problem, though: the user needs real-time feedback of how I’m converting their input. To do this, I used the change event, which I’ve been using since I was born into JavaScript. It worked like a charm.

Then 4 days ago, it broke. Chrome broke it by fixing this bug. The behavior described in the bug report (from 2012!) was the behavior I had come to accept as correct. Fixing this bug meant breaking my code, to conform to spec! I had no idea, because I learned this by using it, not by reading the spec.

Should I read the spec of every new tag in HTML5?

Yes.

I’ve learned a lot by doing, but especially in a distributed development field such as the web, the standards do need to be read. A lot of people have broken up the spec into shiny chunks that are easily digested. However, in this case, I can’t find a single mention of the expected behavior of the change event for [type=range]. The spec draft at W3.org describes the change event for inputs, generally, as firing “when the value is committed, if that makes sense for the control, or else when the control loses focus. In all cases, the input event comes before the corresponding change event (if any).”

I had never even heard of the input event. This is the event that I should have been using in the first place, since I’m reacting to someone’s input, not their decision (which would be the change event).

I will continue to learn by doing; I can’t help it, and I can’t do without it. But, the next time I’m aware that I’m doing something new, I’m going to jog over to W3.org to check that I’m leveraging stuff that’s going to be around for a while.

0 thoughts on “The Problem with Learning by Doing: DOM events”

  1. The world of online casinos has revolutionized the trail people sagacity gambling, bringing the kick and unrest of well-known casinos freedom to your fingertips. With the begin of technology, playing online casino games in compensation real change has never been easier or more accessible.

    What Are Online Casinos

    Online casinos are digital platforms where players can wager true lolly on a variety of games, such as slots, poker, blackjack, roulette, and more. These websites or apps are licensed and regulated, ensuring blonde room and safe keeping on every user.

    Simplified Actual Money Casino Games

    – Depression Machines: Unreserved to contend with with the future in behalf of great wins, slots are the most in demand best supply online gamblers play for real money slots
    – Poker: Players can exam their skills in multiple versions against authentic opponents for everyone the world.
    – Blackjack: Known as a replacement for its unadorned rules and shaky family incisiveness, blackjack is a favorite for those seeking strategy.
    – Roulette: The spinning vicinity game offers a collection of betting options and great excitement.
    – Unexploded Businessman Games: These games invoke occasion the faithful casino trial haven, with honest dealers streaming in real time.

    Benefits of Playing for Trustworthy Money

    – Lolly Prizes: Sincere lolly means authentic winnings. Multitudinous casinos offer massy jackpots and promotional bonuses.
    – Presentation: Enjoy your favorite games whenever you desire, from the cheer of your territory or on the go.
    – Difference: Online casinos stress hundreds, now thousands, of different games and betting limits because every player.
    – Bonuses and Promotions: Unfamiliar and commonplace players can take betterment of desirable bonuses, unattached spins, and trustworthiness programs.

    How to Get Started

    1. Opt a respected online casino with pragmatical reviews and decent licenses.
    2. Jot an account by innards not at home your adverse details.
    3. Plunk down funds using hypothecate payment methods such as credit cards, e-wallets, or cryptocurrency.
    4. Special your favorite games and start playing as far as something real money.

    Cover and Security

    It is vital to ensure the online casino you pick out is all right and trustworthy. Look into regulated sites with SSL encryption, front-office gaming policies, and not guilty terms and conditions.

    Responsible Gambling

    While playing online casino games can be kid and satisfying, it is vital to set limits and speculate responsibly. Most reputable casinos step tools to assist players manage their spending and refrain from unwell gambling habits.

    Conclusion

    Online casinos submit a within easy reach, delightful, and potentially beneficial nature to contend in your favorite casino games. With a wide sort of games, moving bonuses, and licit money prizes, it’s no be astonished question millions of players all the set are enjoying the online casino experience. Always elect reliable platforms and muse on to production responsibly!

Leave a Reply

Your email address will not be published.