Skip to content

Commit

Permalink
Make sure (defficient) APPLET, OBJECT and EMBED elements are extended…
Browse files Browse the repository at this point in the history
… with simulated methods in IE8. Return early if _extendedByPrototype is present on an element.
  • Loading branch information
Juriy Zaytsev committed May 30, 2009
1 parent de1a529 commit 6c35231
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG
@@ -1,3 +1,5 @@
* Make sure (defficient) APPLET, OBJECT and EMBED elements are extended with simulated methods in IE8. Return early if _extendedByPrototype is present on an element. (Tobie Langel, kangax)

* Add missing semicolons. This allows to strip newlines from distribution file. (kangax)

* Fix `Template#evaluate` "eating" previous character if `null` was returned from `toTemplateReplacements` function. (Nir, Jürgen Hörmann, kangax)
Expand Down
7 changes: 4 additions & 3 deletions src/dom/dom.js
Expand Up @@ -1638,10 +1638,11 @@ Element.extend = (function() {
// since creating an APPLET element in IE installations without Java triggers warning popup, which we try to avoid
if (HTMLOBJECTELEMENT_PROTOTYPE_BUGGY) {
return function(element) {
var t;
if (element && (t = element.tagName)) {
if (/^(?:object|applet|embed)$/i.test(t)) {
if (element && typeof element._extendedByPrototype == 'undefined') {
var t = element.tagName;
if (t && (/^(?:object|applet|embed)$/i.test(t))) {
extendElementWith(element, Element.Methods);
extendElementWith(element, Element.Methods.Simulated);
extendElementWith(element, Element.Methods.ByTag[t.toUpperCase()]);
}
}
Expand Down
12 changes: 12 additions & 0 deletions test/unit/dom_test.js
Expand Up @@ -641,10 +641,19 @@ 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);
Expand All @@ -669,6 +678,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() {
Expand Down

1 comment on commit 6c35231

@savetheclocktower
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Committed.

Please sign in to comment.