472,789 Members | 1,283 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,789 software developers and data experts.


I switched to using this function to create element:
function elem(name, attrs, style, text) {
var e = document.createElement(name);
if (attrs) {
for (key in attrs) {
if (key == 'class') {
e.className = attrs[key];
} else if (key == 'id') {
e.id = attrs[key];
} else {
e.setAttribute(key, attrs[key]);
if (style) {
for (key in style) {
e.style[key] = style[key];
if (text) {
return e;
so instead of the "old" way:
var oMyDiv = document.createElement("DIV");
oMyDiv.className = "testclass";

I use that function :
var oMyDiv = elem('DIV', {'id':'testid', 'class':'testclass'});

The rendered source shows this:
<div extend=" function (object) {return Object.extend.apply(this, [this,
object]); } "
class="testclass" id="testid">
Question: I don';t understand the "EXTEND" part......anyways does it look
legit/right ?
Any if you please put this "extend=" function (object) {return
Object.extend.apply(this, [this, object]); } "
in English ;)

Sep 24 '05 #1
2 1724
Boobie wrote:
Any if you please put this "extend=" function (object) {return
Object.extend.apply(this, [this, object]); } "
in English ;)

Here's some info on the Object.apply method:


Sep 24 '05 #2
"Boobie" <bo********@mailnull.com> writes:
function elem(name, attrs, style, text) { for (key in attrs) { .... e.setAttribute(key, attrs[key]); .... var oMyDiv = elem('DIV', {'id':'testid', 'class':'testclass'});
.... giving:
<div extend=" function (object) {return Object.extend.apply(this, [this,
object]); } "
class="testclass" id="testid"> Question: I don';t understand the "EXTEND" part......anyways does it look
legit/right ?

It seems you have givent the Object.prototype an extra property, i.e.,

Object.prototype.extend = function(object) {
return Object.extend.apply(this, [this, object]);

Since that means that *all* objects inherit the "extend" property,
also your "attrs" object will have it, so it has three attributes:
"id", "class" *and* "extend". The last one is a function, which
gives the value you see when it is converted to a string.

This is a good example of why extending Object.prototype is dangerous,
and should only be done with extreme care, since all other code running
in the same environment should know about it.

Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Sep 24 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: sdhyok | last post by:
I think the two script should produce the same results, but not. Why? ---------------- Script #1 ls = ls.extend() print ls -> --------------- Script #2
by: Charles Fineman | last post by:
Say i've got a type that appears in a request... say it represents a shipment. I want it to contain things like from and to address elements as well as a sequence of the pieces being shipped. ...
by: Alan Little | last post by:
I have a two-column layout, with a background image in the left panel. If the content of the right column is longer than the left, I would like to have the background image repeat all the way down....
by: Mike Chamberlain | last post by:
Hi all. I'm trying to extend the Microsoft Enterprise Library Data Access Application Block (http://msdn.microsoft.com/library/en-us/dnpag2/html/daab.asp?frame=true) to work with a Borland...
by: Joseph Turian | last post by:
Hi, What is the safest manner to extend search path for modules, minimizing the likelihood of shooting oneself in the foot? The system (which includes scripts and their shared modules) may be...
by: Jerzy Karczmarczuk | last post by:
Gurus, before I am tempted to signal this as a bug, perhaps you might convince me that it should be so. If I type l=range(4) l.extend() l gives , what else... On the other hand, try
by: aaa | last post by:
Im using a datagrid object to view data, Is it possible to extend selected row and show other details at the extended part of the row? If the answer is Y: Is it part of the datagrid's...
by: rick | last post by:
hi Is there a DB2 equivalent of Informix.Extend function? or please help me the best way to create one Thanks rick
by: jacobstr | last post by:
I've noticed Object.extend used in a few different ways and I'm having trouble distinguishing why certain usages apply to a given situation. On line 804 Ajax.Base is defined as follows: ...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
by: lllomh | last post by:
How does React native implement an English player?
by: Mushico | last post by:
How to calculate date of retirement from date of birth
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.