Bug Tracker

Modify

Ticket #11715 (closed bug: duplicate)

Opened 13 months ago

Last modified 13 months ago

Passing attributes on object creation is inconsistent / depends on casing

Reported by: frederik.ring@… Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.7.2
Keywords: Cc:
Blocking: Blocked by:

Description

I was recently encountering the "problem" described here: http://bugs.jquery.com/ticket/10125

Yet I found out that when you use 'Width' and 'Height' (upper-casing the first letter) the passed pairs will be interpreted as attributes, not as CSS.

See this demo jsfiddle:  http://jsfiddle.net/Lfh9F/

Maybe this is desired behavior as well, yet I have to admit that I find it highly confusing.

Change History

comment:1 Changed 13 months ago by rwaldron

  • Status changed from new to closed
  • Resolution set to duplicate

comment:2 Changed 13 months ago by rwaldron

Duplicate of #10125.

comment:3 Changed 13 months ago by frederik.ring@…

Actually I don't think this is a duplicate. What I was talking about is that:

$('<canvas/>',{'id':'a', 'width':100, 'height':100})

will create

<canvas id="a" style="width: 100px; height: 100px;"></canvas>

whereas

$('<canvas/>',{'id':'b', 'Width':100, 'Height':100})

will create

<canvas id="b" width="100" height="100"></canvas>

In case this is desired behavior it might be interesting to mention this in the api-docs. Thanks.

comment:4 Changed 13 months ago by dmethvin

There are so many ways to do things wrong, we tend to only mention the really common ones. Besides it's totally up to the document how to interpret mixed-case attributes. HTML DOM always ignores case. XML and XML-based documents do not. The developer needs to know some of this, it can't fall totally in the hands of jQuery to train people about every aspect of development.

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.