And what would this mean in the case where I have downloaded an XML document via $.ajax()? That $ will not be an observer of the $(document) instance, will it?
Or if I create fragments that are not yet in the DOM, such as var foo = document.createElement('div'); $(foo)... That instance should not be a listener, should it? On Thu, Dec 17, 2009 at 12:50 AM, DBJDBJ <dbj...@gmail.com> wrote: > MutationEvents are fired whenever and wherever any CRUD operation is > done on the document tree. > To do this, one needs to redesign jQuery to follow an Observer > pattern. > Where observable is a single instance of jQ 'mutator'. Imagine that > instead of this (currently in core.js ) > > // Handle $(""), $(null), or $(undefined) > if ( !selector ) { return this; } > > We do this (and a lot more) : > > // Handle $(""), $(null), or $(undefined) > if ( !selector ) { return rootjQuery ; } > > Now we have rootjQuery (aka $(document) ) as an single observable > which sends MutationEvents to 'observers', which are all the other $ > instances. > So every $(selector,context) is *also* an observer of the rootjQuery > (aka 'mutator'). rootjQuery publishes (fires) MutationEvents to which > all the other '$' are subscribed. > In that (imaginary) context, every '$' is an 'client' of the > rootjQuery which is a single 'mutator'. The only one who deals with > DOM. > The 'others' are just sending it commands to be executed on the > document tree, by rootjQuery. Which does it and signals back to all > the registered listeners, by publishing to all the subcribers, > appropriate MutationEvent objects. > > Important moment here: "to ALL the subscribers". If one '$' removes a > node, all the other '$' are sent a MutationEvent about the removal. > > All of this would apply to jQ 'mutator' in every browser host. > Regardless of if the browser implements MutationEvents natively or > not. For the ones that do not, some internal MutationEvents mechanism > will be implemented. Much like Sizzle implements querySelectorAll() if > host is not having it. > > This obviously is a "non trivial" change to how jQ works today. Or any > other glow, dojo, moo, extjs, fusejs or prototype I know of. > But, is the only legal way, to have 2 or more simultaneous dom > document tree users. > Same applies (conceptually) to any situation with 2 or more users of a > single persistent structure. > > --DBJ > > -- > > You received this message because you are subscribed to the Google Groups > "jQuery Development" group. > To post to this group, send email to jquery-...@googlegroups.com. > To unsubscribe from this group, send email to > jquery-dev+unsubscr...@googlegroups.com<jquery-dev%2bunsubscr...@googlegroups.com> > . > For more options, visit this group at > http://groups.google.com/group/jquery-dev?hl=en. > > > -- John Arrowwood John (at) Irie (dash) Inc (dot) com John (at) Arrowwood Photography (dot) com John (at) Hanlons Razor (dot) com -- http://arrowwood.blogspot.com Mike Ditka <http://www.brainyquote.com/quotes/authors/m/mike_ditka.html> - "If God had wanted man to play soccer, he wouldn't have given us arms." -- You received this message because you are subscribed to the Google Groups "jQuery Development" group. To post to this group, send email to jquery-...@googlegroups.com. To unsubscribe from this group, send email to jquery-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/jquery-dev?hl=en.