domassistant namespaced

9 views
Skip to first unread message

rborn

unread,
Jan 25, 2010, 3:34:11 PM1/25/10
to DOMAssistant
Hi
Thanx for approving my membership.
I have a question:

How nice it plays DA with other frameworks? I am trying to obtain a
namespaced version because in some cases might interfere with other
functions form other frameworks.

I removed the

this.applyMethod.call(window, "$", this.$);
this.applyMethod.call(window, "$$", this.$$);

but still remains some methods added to the dom, like window.addEvent,
that might interfere with other ( mootools for example )

Is possible to make it purely namespaced?
thanks

Robert Nyman

unread,
Jan 25, 2010, 3:44:10 PM1/25/10
to domass...@googlegroups.com
Hi,

I used to be part of developing DOMAssistant, but I'm not anymore. Off the top of my head, though, I would say that generally you could probably make it work, but there are some minor kinks to work out (like the ones you mention).

Best regards,
Robert



--
You received this message because you are subscribed to the Google Groups "DOMAssistant" group.
To post to this group, send email to domass...@googlegroups.com.
To unsubscribe from this group, send email to domassistant...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/domassistant?hl=en.


Dan Tamas

unread,
Jan 25, 2010, 3:51:29 PM1/25/10
to domass...@googlegroups.com
Thanks for your reply
any ideas?
basically i would like to get rid of document and window methods pollution

but if i do something like DomAssistant.window =  window

a DomAssistant.window.myFunct =  function(){} will be found in  window.myFunct too :(


Robert Nyman

unread,
Jan 25, 2010, 3:57:03 PM1/25/10
to domass...@googlegroups.com
Well, the parts you mentioned needs to be attended to. Perhaps it might be an option to use the closure of the core object and a method in there to access a private variable, declared at the beginning.

Does that make sense? Is it a good pointer to start?

Also, Cheng Hong developing DOMAssistant now might have some ideas how to achieve this compliance.

Good luck!


Best regards,
Robert

Dan Tamas

unread,
Jan 25, 2010, 4:29:24 PM1/25/10
to domass...@googlegroups.com
yeah, seems clear (let's see whan i'll try to implement it :D )
thanks

chenghong

unread,
Jan 25, 2010, 10:00:19 PM1/25/10
to DOMAssistant
Let me know if you came out with something. I'll try to explore the
possibility too =)

Chenghong

On Jan 26, 5:29 am, Dan Tamas <dan.ta...@gmail.com> wrote:
> yeah, seems clear (let's see whan i'll try to implement it :D )
> thanks
> --
> Regards,

> Dan Tamashttp://kroppr.rborn.infohttp://www.rborn.info


>
> On 25 Jan 2010, at 21:57, Robert Nyman wrote:
>
>
>
> > Well, the parts you mentioned needs to be attended to. Perhaps it  
> > might be an option to use the closure of the core object and a  
> > method in there to access a private variable, declared at the  
> > beginning.
>
> > Does that make sense? Is it a good pointer to start?
>
> > Also, Cheng Hong developing DOMAssistant now might have some ideas  
> > how to achieve this compliance.
>
> > Good luck!
>
> > Best regards,
> > Robert
>

> > On Mon, Jan 25, 2010 at 9:51 PM, Dan Tamas <dan.ta...@gmail.com>  


> > wrote:
> > Thanks for your reply
> > any ideas?
> > basically i would like to get rid of document and window methods  
> > pollution
>
> > but if i do something like DomAssistant.window =  window
>
> > a DomAssistant.window.myFunct =  function(){} will be found in  
> > window.myFunct too :(
>
> > --
> > Regards,
> > Dan Tamas
> >http://kroppr.rborn.info
> >http://www.rborn.info
>
> > On 25 Jan 2010, at 21:44, Robert Nyman wrote:
>
> >> Hi,
>
> >> I used to be part of developing DOMAssistant, but I'm not anymore.  
> >> Off the top of my head, though, I would say that generally you  
> >> could probably make it work, but there are some minor kinks to work  
> >> out (like the ones you mention).
>
> >> Best regards,
> >> Robert
>

Dan Tamas

unread,
Jan 26, 2010, 7:00:39 AM1/26/10
to domass...@googlegroups.com
Well, I think the only way is to remove any stuff that is polluting
the window and the document, add an event "DOMLoaded" similar to
DOMReady
and avoid to attach methods if somebody makes

DOMAssistant.$(window) or DOMAssistant.$(window);

of course I think in this case the functions cannot be chained
anymore( and I believe this is the main issue )

Let me know what you think

chenghong

unread,
Jan 26, 2010, 11:27:20 AM1/26/10
to DOMAssistant
Hi, I've committed a latest snapshot that has built-in support for
avoiding namespace collision. Get it from
http://code.google.com/p/domassistant/source/browse/#svn/trunk

Just call
DOMAssistant.harmonize();

first thing after including the DOMAssistant script. Let me know what
you think =)


Chenghong

On Jan 26, 8:00 pm, Dan Tamas <dan.ta...@gmail.com> wrote:
> Well, I think the only way is to remove any stuff that is polluting  
> the window and the document, add an  event "DOMLoaded" similar to  
> DOMReady
> and avoid to attach methods if somebody makes
>
> DOMAssistant.$(window) or DOMAssistant.$(window);
>
> of course I think in this case the functions cannot be chained  
> anymore( and I believe this is the main issue )
>
> Let me know what you think
>
> --
> Regards,

> Dan Tamashttp://kroppr.rborn.infohttp://www.rborn.info

Dan Tamas

unread,
Jan 26, 2010, 2:17:04 PM1/26/10
to domass...@googlegroups.com
This is cool, but still this fixes only one issue - the $/$$ name
conflict

there are some issues still with addEvent for example

considering we harmonized it, we will have to do this to get the element

DOMAssistant.$('#_the_id')

but if we do this:

DOMAssistant.$(window)

We will have window.addEvent that will overwrite the addEvent function
of mootools.

Until now I only added DOMAssistant.DOMLoad.DOMLoaded() that acts when
the page is fully loaded

DOMLoaded : function() {

for (var i=0, il=arguments.length, funcRef; i<il; i++) {
funcRef = arguments[i];
if (!funcRef.DOMLoaded && !addedStrings[funcRef]) {
if (typeof funcRef === "string") {
addedStrings[funcRef] = true;
funcRef = new Function(funcRef);
}
funcRef.DOMLoaded = true;
// functionsToCall.push(funcRef);
if ( DOMAssistant.isIE ) {
window.attachEvent('onload',funcRef);
}
else {
window.addEventListener('load',funcRef,false);
}
}
}

},

this in DOMAssistant.DOMLoad

and at the end of the file.

DOMAssistant.DOMLoaded = DOMAssistant.DOMLoad.DOMLoaded;


I am thinking on something like

DOMAssistant.Window that will be some sort of proxy for the window
variable, and will be responsible to allow stuff like
DOMAssistant.$(window).addEvent
without actually adding the addEvent method to the window.
Also with DOMAssistant.Document


What about some dimensions? :D
like $(id).getSize, etc ?

chenghong

unread,
Jan 26, 2010, 10:26:40 PM1/26/10
to DOMAssistant
You are right, calling $/$$ on any objects, including window and
document, will extend them with DOMAssistant's methods. I'm afraid
this is not something easy to avoid.

Just wondering, under what circumstances would you need to mix
libraries in this way?


Chenghong

Dan Tamas

unread,
Jan 27, 2010, 5:27:44 AM1/27/10
to domass...@googlegroups.com
Hi
Well , if you take a look at my signature ( kroppr.rborn.info ) you
will see a script I built.
It really needs to work in any circumstances.
Now I use mootools but the way I make it work makes me loose a lot of
performance.

You can include the domload function I made if you wish :)

Reply all
Reply to author
Forward
0 new messages