For god's sake, don't redefine a standard browser property!

On Sep 14, 2007, at 3:59 PM, Nicolás Sanguinetti wrote:

> Thought: what about declaring this method using a setter? Won't affect
> IE, and works fine in Mozilla, without touching Prototype's source.
>
> something along the lines of (haven't tested, thinking on gmail):
>
> HTMLElement.prototype.__defineSetter__("innerHTML", function(html) {
>   var newEl = this.cloneNode(false);
>   newEl.innerHTML = html;
>   this.parentNode.replaceChild(newEl, this);
>   return html;
> });
>
> http://developer.mozilla.org/en/docs/ 
> Core_JavaScript_1.5_Guide:Creating_New_Objects:Defining_Getters_and_Se 
> tters
>
> This will work in Mozilla, won't work in IE, and you don't need to
> modify any existing code. If it works, that is :P
>
> -Nicolas
>
> On 9/13/07, Mislav Marohnić <[EMAIL PROTECTED]> wrote:
>> On 9/13/07, Ryan Gahl <[EMAIL PROTECTED]> wrote:
>>
>>>  You'd be losing attached event observers anyway when you do a  
>>> plain old .innerHTML = "..."
>>
>> He meant the target element, not the subelements. Yeah, it will  
>> remove event handlers. Prototype, however, is able to remove all  
>> attached handlers automatically and re-applying them on the new  
>> element.
>>
>> However, you'll be losing the reference to the old target element  
>> if you ever had one.
>>
>>   var element = $('foo')
>>   element.update("Yeah baby!")
>>   element --> no longer in the document tree; you're screwed
>>
>> So there are gotchas, true.
>>
>>
>>>
>>
>
> >


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to