Opened 9 years ago

Closed 8 years ago

Last modified 5 years ago

#11444 closed defect (fixed)

Many dijits use dojo.marginBox just to get the width or height, which is very expensive

Reported by: Shane O'Sullivan Owned by: bill
Priority: high Milestone: 1.7.6
Component: Dijit Version: 1.5.0b2
Keywords: Cc: Douglas Hays
Blocked By: Blocking:

Description

Many dijit widgets use dojo.marginBox just to get the width or the height of a node, e.g.

var width = dojo.marginBox(this.domNode).w;

This is very wasteful, and slow in IE6 and IE7. In these browsers, just reading the node.offsetLeft is expensive and should be avoided if at all possible.

A more simple function could be added that just returns the width and the height of a node, and not its left and top position.

Change History (6)

comment:1 Changed 9 years ago by bill

Cc: Douglas Hays added

I think the idea for 2.0 is that dojo.marginBox() just return the size, and people use dojo.position() to get the position relative to <body>, or access offsetLeft/offsetTop directly to get the position relative to the containing block (with position:relative/absolute).

Probably for now, you can change most of dijit's dojo.marginBox() calls to dojo.position(). dojo.position() returns the border-box size in addition to the offset relative to <body>, without accessing offsetLeft/offsetTop.

Shane - feel free to update this for 1.6, if you are volunteering. Otherwise will probably wait for 2.0.

comment:2 Changed 9 years ago by bill

Milestone: tbd2.0
Owner: set to Shane O'Sullivan

comment:3 Changed 8 years ago by bill

Milestone: 2.01.8
Owner: changed from Shane O'Sullivan to bill
Status: newassigned

There are just a few cases that I see. I'm going to change them to dojo.position() and close this ticket.

comment:4 Changed 8 years ago by bill

Resolution: fixed
Status: assignedclosed

In [28029]:

Prefer dojo.position() over dojo.marginBox(), fixes #11444 !strict.

comment:5 Changed 5 years ago by Bill Keese <bill@…>

In cde5800a07a0b6f8eccf49b30d2bccc106efd522/dijit:

Error: Processor CommitTicketReference failed
Unsupported version control system "git": Can't find an appropriate component, maybe the corresponding plugin was not enabled? 

comment:6 Changed 5 years ago by bill

Milestone: 1.81.7.6
Note: See TracTickets for help on using tickets.