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:
parent
703e988745
commit
d655665fb6
@ -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)
|
||||
|
@ -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);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user