Skip to main content

Bug Tracker

Side navigation

#8089 closed bug (invalid)

Opened January 29, 2011 10:08AM UTC

Closed January 29, 2011 11:38AM UTC

.attr(map): Quotes seem not to be optional

Reported by: anonymous Owned by:
Priority: low Milestone: 1.next
Component: attributes Version: 1.4.4
Keywords: Cc:
Blocked by: Blocking:
Description

Don't know whether this is a bug in jquery, a bug in the api-documentation http://api.jquery.com/attr/ or just a missing feature, but I thought it is worth reporting:

This does not work without quotes:

$mydialog.attr({
    role            : 'dialog',
    aria-hidden     : 'false',
    aria-labelledby : 'top'
});

Error in line aria-hidden: Missing : after property id

It works with quotes only:

$mydialog.attr({
    'role'            : 'dialog',
    'aria-hidden'     : 'false',
    'aria-labelledby' : 'top'
});
Attachments (0)
Change History (2)

Changed January 29, 2011 10:54AM UTC by Utkarsh comment:1

_comment0: `{aria-hidden : 'false'}` is invalid javascript syntax. You _need_ to enclose the key in quotes if they contain a `-`. \ 1296298539647905

{aria-hidden : 'false'} is invalid javascript syntax. You ''need'' to enclose the key in quotes if they contain a -.

Changed January 29, 2011 11:38AM UTC by jitter comment:2

component: unfiledattributes
description: Don't know whether this is a bug in jquery, a bug in the api-documentation http://api.jquery.com/attr/ or just a missing feature, but I thought it is worth reporting: \ \ This does not work without quotes: \ $mydialog.attr({ \ role : 'dialog', \ aria-hidden : 'false', \ aria-labelledby : 'top' \ }); \ \ Error in line aria-hidden: Missing : after property id \ \ It works with quotes only: \ \ $mydialog.attr({ \ 'role' : 'dialog', \ 'aria-hidden' : 'false', \ 'aria-labelledby' : 'top' \ }); \ \ \ Don't know whether this is a bug in jquery, a bug in the api-documentation http://api.jquery.com/attr/ or just a missing feature, but I thought it is worth reporting: \ \ This does not work without quotes: \ {{{ \ $mydialog.attr({ \ role : 'dialog', \ aria-hidden : 'false', \ aria-labelledby : 'top' \ }); \ }}} \ Error in line aria-hidden: `Missing : after property id` \ \ It works with quotes only: \ {{{ \ $mydialog.attr({ \ 'role' : 'dialog', \ 'aria-hidden' : 'false', \ 'aria-labelledby' : 'top' \ }); \ }}}
priority: undecidedlow
resolution: → invalid
status: newclosed

Thanks for taking the time to contribute to the jQuery project by writing a bug report.

After checking your report I conclude that this isn't a bug in jQuery but, as Utkarsh already pointed out, invalid javascript syntax.