Bug Tracker

Opened 6 years ago

Closed 6 years ago

#13740 closed bug (duplicate)

Trying to set or retrieve "loop" attribute fails

Reported by: ph0xb01@… Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.9.1
Keywords: Cc:
Blocked by: Blocking:


Let's say I have: <div loop="1"><div>

This is what I get trying to read or set attribute



$('div').attr('loop', 1)

[<div loop="loop"><div>]

Change History (3)

comment:1 Changed 6 years ago by anonymous

Some more info: Tried on Chrome 26 and 28, and Firefox 20.0. All on Windows 7 64bit jQuery 1.9.1

Here's a quick jsFiddle: http://jsfiddle.net/CTDkJ/

comment:2 Changed 6 years ago by m_gol

That's because loop is treated as a boolean attribute because it's used as such in HTMLMediaElement:
https://developer.mozilla.org/en-US/docs/DOM/HTMLMediaElement The element constructor is not checked in jQuery when matching the attribute name against predefined boolean ones; changing this method would increase jQuery size and there are not a lot of such boolean attributes.

Anyway, if you use custom attributes without prepending them with data-, it's your responsibility to make sure those names don't conflict with built-in ones, custom attributes are required to be prepended by data- per HTML5 spec.

comment:3 Changed 6 years ago by m_gol

Resolution: duplicate
Status: newclosed

Duplicate of #12095.

Note: See TracTickets for help on using tickets.