Added: 5 months ago
From: GoogleDevelopers
Views: 10,993
Sort by time | Sort by thread (beta)

Link to this comment:

Share to:

All Comments (14)

Sign In or Sign Up now to post a comment!
  • Does the dataset API have a way to delete the attribute, meaning actually remove it like $0.removeAttribute('data-event­') would?

  • @RyanVanEtten `delete $0.dataset.event` works for removing.

  • lapel mic please...thank you

  • Just happened to find this video and followed most of it since I program in jQuery. Not sure how this compares to that. Is this something new that will be in future browsers' javascript interpreters?

  • both matchesSelector  and matchMedia i see no usage scenarios for really.

    can you provide some, the one you specified didn't really make good sense.

    classList i'm already using and i love it

    dataset useful maybe but why was it really added for ?

    textContent is just confusing when you read about innetText, etc that all nearlt do the same thing :S

  • @labobo matchesSelector is ideal for event delegation. Also has some unit test uses. matchMedia you can have an event listener bound to when orientation or screensize changes, and you know that event matches when your CSS mq's are switching over. If your styles are using MQs (media queries) then the JS api lets you write behavior that will match.

  • I see you started to type jQuery there ;)

    Really cool stuff seeing this implemented into standard JS, thanks for the video.

  • apple sucks.

  • @STHayden classList, dataset and matchesSelector can be found on caniuse.com. For textContent and matchMedia there are browser compatibility tables on MDN.

  • Btw for those of you who'd like to know where that stuff is specified:

    classList and dataset --> HTMLElement interface --> HTML Living Standard chapter 3.2.2

    textContent --> Node interface --> DOM4 chapter 5.2

    matchesSelector --> Element interface (extension) --> Selectors API 2 chapter 6.2

    window.matchMedia --> Window interface (extension) --> CSSOM View chapter 4

  • very awesome. would love to see more of these. Also would love if you said where current browser support for these stand and if there is any known timeline for future browser improvements. very cool though!

  • You didn't mention you can also add data attributes using the tiny data api:

    element.dataset.foo = 'bar'

  • first

Loading...
Alert icon
0 / 00Unsaved Playlist Return to active list
    1. Your queue is empty. Add videos to your queue using this button:
      or sign in to load a different list.
    Loading...Loading...Saving...
    • Clear all videos from this list
    • Learn more