Colin, I was just thinking about your statement: "(OTOH I wish that browsers and libraries would object to a very common instance of invalid HTML: duplicate id's)" And how much I agree. This is the result...
(function () { var _domIdentities = function () {}; _domIdentities.prototype = { test: function () { var _error = new Error('Duplicate element ID exists'), _elems = $(document.body).select('*[id]'), _len = _elems.length, _temp = [], _i = 0; for( ; _i < _len ; _i++ ) { if ( _temp.indexOf( _elems[_i].id ) >= 0 ) throw _error + ' "' + _elems[_i].id + '"'; else _temp.push( _elems[_i].id ); } } }; new _domIdentities().test(); delete _domIdentities; })(); Nothing I'd consider perfect.... but I think its an interesting starting point. ... perhaps if DOMNodeInserted and other mutation events where more widely supported. Just some zany ideas. On Wed, Jul 22, 2009 at 5:31 AM, ColinFine <colin.f...@pace.com> wrote: > > > > On Jul 21, 1:52 pm, "Alex McAuley" <webmas...@thecarmarketplace.com> > wrote: > > Each to their own, everyone has their own coding practices and concepts. > > > Indeed. I'm not about to start using '.' or ':' in ID's myself. > > > In PHP and Perl you -could- call "." a heirachial operator as it joins 2 > > nodes (strings for example) together - thus jumping from one to the next > or > > making the bridge (to assimilate them) - which is what it does in > Javascript > > for example (kind of)!!!!. > > I think this is a perverse argument, but I'm not going to get excited > about it. > > > As i said - each to their own but if CSS explicits ".className" as a > > classname then perhaps they should think about not having dots in ID's > > ([0-9Aa-Zz]\-_) would be a better fit for DOM element id's in my opinion. > > Classnames do not allow dots as far as i know. I would've thought the > devs > > of JS libraries wluld have realised that perhaps 0.01% of javascript > > developers in the world would use dots and possibly didnt want the > > performance lack to accomodate these users .... Just my 2 pence worth!!! > > > I think, as Rick implied above, that the designers of CSS selectors > were ill-advised to use symbols which were permitted in id's (I'm > assuming that the HTML spec came before the CSS one, but I haven't > checked). But formally, there are no contexts in which these are > ambiguous. > > But I think it would be wrong for JS libraries to refuse to work just > because you had made certain (valid) choices in your HTML. > (OTOH I wish that browsers and libraries would object to a very common > instance of invalid HTML: duplicate id's) > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Prototype & script.aculo.us" group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~----------~----~----~----~------~----~------~--~---