Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #32143
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: Empty function |
| Date | 2017-01-08 23:40 +0100 |
| Organization | PointedEars Software (PES) |
| Message-ID | <1552504.VLH7GnMWUR@PointedEars.de> (permalink) |
| References | <UPqdnRaDtOBAT-zFnZ2dnUU7-RHNnZ2d@westnet.com.au> <o4sppl$ub7$1@news.albasani.net> <l-ednZuM5IV2ne_FnZ2dnUU7-SXNnZ2d@westnet.com.au> |
Andrew Poulos wrote:
> […] Here is the complete code
>
> var Drag = {
> obj: null,
> init: function(o, posX, posY, minX, minY) {
> if (!o) return;
> o.onmousedown = Drag.start;
> o.root = o;
> o.root.style.left = posX + "px";
> o.root.style.top = posY + "px";
> o.minX = minX;
> o.minY = minY;
> o.root.onDragStart = function() {};
> o.root.onDragEnd = function() {};
> o.root.onDrag = function() {};
As indicated by “o.root.style”, “o.root” appears to store a reference to a
DOM element object. In that case, the latter three lines are error-prone:
They would only work in the MSHTML DOM before version 9 and any DOM
compatible to it. In addition, the names of the standard event-handler
properties are all-lowercase; so in a W3C DOM implementation the referred
object does not have those properties. It is a host object, and assigning
to potentially non-existing property of a host object, thereby attempting
to augment it with properties, is a recipe for disaster.
Since DOM element objects usually do not have “minX” and “minY” properties,
the latter possibility is more likely.
> },
> start: function(e) {
> e = e || window.event;
> var o = Drag.obj = this,
> y = parseInt(o.root.style.top, 10),
> x = parseInt(o.root.style.left, 10);
> o.root.onDragStart(x, y);
Given the augmented code, this line suggests that the author attempted to
augment a host object (see above), and that they have no clue how to
properly dispatch an event to such an object.
--
PointedEars
FAQ: <http://PointedEars.de/faq> | <http://PointedEars.de/es-matrix>
<https://github.com/PointedEars> | <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | Please do not cc me./Bitte keine Kopien per E-Mail.
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Empty function Andrew Poulos <ap_prog@hotmail.com> - 2017-01-08 16:49 +1100
Re: Empty function Martin Honnen <martin.honnen@gmx.de> - 2017-01-08 08:29 +0100
Re: Empty function Andrew Poulos <ap_prog@hotmail.com> - 2017-01-08 20:05 +1100
Re: Empty function Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-01-08 23:40 +0100
Re: Empty function Andrew Poulos <ap_prog@hotmail.com> - 2017-01-09 10:47 +1100
Re: Empty function Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-01-09 01:10 +0100
Re: Empty function JJ <jj4public@vfemail.net> - 2017-01-08 20:53 +0700
Re: Empty function "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2017-01-08 10:02 -0800
Re: Empty function Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-01-08 23:21 +0100
csiph-web