Skip to content

Instantly share code, notes, and snippets.

@bomatson
Created August 10, 2014 17:53
Show Gist options
  • Save bomatson/869f4be303c0122681f0 to your computer and use it in GitHub Desktop.
Save bomatson/869f4be303c0122681f0 to your computer and use it in GitHub Desktop.

Chapter 11 Thoughts

Feature simulation - why rebuild the feature as a fallback, wouldn’t that take up a lot of dev time and be a little error prone?

Object detection seems like the best way to handle browser inconsistencies - if the object has this property, use it

function bindEvent(elem, type, handle) {
  if (elem.addEventListener) {
    elem.addEventListener(type, handle, false);
  } else if (elem.attachEvent) {
    elem.attachEvent(‘on’ + type, handle);
  }
}

For event handler bindings - is it still not possible to know if a bound event has been fired? Mouseover is hard to use in reusable code, for example, since we need to bind the listener and then wait for a user interaction

@gilesbowkett
Copy link

The simple answer re: feature simulation is "this is why polyfill libraries (e.g. Modernizr) exist." The more complicated answer is that every team comes up with their own answer re: how much dev time they can afford for that kind of thing, and how error-prone is too error-prone. The reality is, at that point, you're doing the job the browser vendor was supposed to do, so it's always a diminishing returns situation. However, when you create a user interface, you're really creating an ecology of interactions, and if one interaction goes out the window, a perfect user interface should adjust its entire ecology accordingly - which basically guarantees that a serious perfectionist would lose their mind if they worked in web/UX design. So sometimes the devs have to deal with that stuff just to keep the design team from going crazy, or because it's in the company's interest to pretend that the web is more reliable than it is, or because writing polyfills is less expensive than staffing enough tech support for every person out there with an old computer.

The most important practical lessons from this, in my opinion, are a) always be grateful for projects like Modernizr and the ppl who do the hard work to make them happen, and b) the front end of a web application is almost inevitably going to be a clusterfuck. Fortunately b) is way less true than it used to be, mainly because of a). The other takeaway, from a running-the-company perspective, is that this why some designers absolutely love mobile apps.

Re: event firing, I think it's not that you don't know if the bound event's been fired, but that you can only check for binding mechanisms, not the conditions under which the browser fires a particular event.

@gilesbowkett
Copy link

btw I literally had a dream about the topics in chapter 12, where I realized that, when it comes to events, you can model the DOM as a somewhat deranged equivalent to the method lookup chain in Ruby (or indeed JavaScript), because of the way they bubble up the DOM, looking for an appropriate handler.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment