Re: Selectors API naming

On Mon, 29 Jan 2007 06:54:04 +0100, Maciej Stachowiak <mjs@apple.com>  
wrote:

> * - This seems unlikely in any case since they are Document methods; and  
> surely things like getAttribute and setAttribute exist in non-DOM code,  
> but thanks to the magic of object oriented programming and the fact that  
> such names are class-scoped this is not a big problem

Maybe not a big problem but it is still a problem because of the wonderful  
"with" statement. I remember a BT.com CC number validation script break  
because they did

with(document.forms[0]){
 prefix='foo'; // clashes with element.prefix
}

and yesterday or so the same issue prevented form submission in Opera on a  
site where someone did

with(input){
 var pattern='foo'; // clashes with WebForms2 input.pattern
}

It would be nice to have the get() / getBySelector() method on Node as  
well (like getElementsByTagName is) and then I'm absolutely sure we'll run  
into pages that say

<script>function getAll(){ ... }</script>
<body onload="getAll() /* um, you meant YOUR function and not  
body.getAll()? sorry, you're dead. */">

So a longer and more descriptive name and less web evangelism and patching  
efforts :-)

-- 
Hallvord R. M. Steen
Core QA JavaScript tester, Opera Software
http://www.opera.com/
Opera - simply the best Internet experience

Received on Monday, 29 January 2007 14:40:01 UTC