Make sure (defficient) APPLET, OBJECT and EMBED elements are extended with simulated methods in IE8. Return early if _extendedByPrototype is present on an element.

This commit is contained in:
Juriy Zaytsev 2009-05-30 01:23:33 -04:00 committed by Andrew Dupont
parent 703e988745
commit d655665fb6
3 changed files with 26 additions and 11 deletions

View File

@ -1,3 +1,5 @@
* Make sure (deficient) APPLET, OBJECT and EMBED elements are extended with simulated methods in IE8. Return early if `_extendedByPrototype` is present on an element. (Tobie Langel, kangax)
* Replace array creation and `Array#include` with a more efficient `RegExp#test`. (kangax)
* Reorganize the way `ElementExtensions` are defined. Make sure elements used in SpecificElementExtensions are cleaned up. (kangax)

View File

@ -1685,16 +1685,12 @@ Element.extend = (function() {
if (HTMLOBJECTELEMENT_PROTOTYPE_BUGGY &&
HTMLAPPLETELEMENT_PROTOTYPE_BUGGY) {
return function(element) {
if (element && element.tagName) {
var tagName = element.tagName.toUpperCase();
if (tagName === 'OBJECT' || tagName === 'APPLET') {
if (element && typeof element._extendedByPrototype == 'undefined') {
var t = element.tagName;
if (t && (/^(?:object|applet|embed)$/i.test(t))) {
extendElementWith(element, Element.Methods);
if (tagName === 'OBJECT') {
extendElementWith(element, Element.Methods.ByTag.OBJECT)
}
else if (tagName === 'APPLET') {
extendElementWith(element, Element.Methods.ByTag.APPLET)
}
extendElementWith(element, Element.Methods.Simulated);
extendElementWith(element, Element.Methods.ByTag[t.toUpperCase()]);
}
}
return element;
@ -2008,4 +2004,4 @@ Element.addMethods({
}
return Element.extend(clone);
}
});
});

View File

@ -641,6 +641,20 @@ new Test.Unit.Runner({
},
testElementExtend: function() {
Element.Methods.Simulated.simulatedMethod = function() {
return 'simulated';
};
Element.addMethods();
function testTag(tagName) {
var element = document.createElement(tagName);
this.assertEqual(element, Element.extend(element));
// test method from Methods
this.assertRespondsTo('show', element);
// test method from Simulated
this.assertRespondsTo('simulatedMethod', element);
}
var element = $('element_extend_test');
this.assertRespondsTo('show', element);
@ -665,6 +679,9 @@ new Test.Unit.Runner({
this.assertEqual(textnode, Element.extend(textnode));
this.assert(typeof textnode['show'] == 'undefined');
}, this);
// clean up
delete Element.Methods.Simulated.simulatedMethod;
},
testElementExtendReextendsDiscardedNodes: function() {
@ -1490,4 +1507,4 @@ function preservingBrowserDimensions(callback) {
} finally {
window.resizeTo(original.width, original.height);
}
}
}