prototype: Avoid breaking Element.prototype in browsers which support it. Closes #11004.

This commit is contained in:
Tobie Langel 2008-02-04 23:22:18 +00:00
parent 2830ac2ac5
commit 7821b989fe
3 changed files with 11 additions and 0 deletions

View File

@ -1,3 +1,5 @@
* Avoid breaking Element.prototype in browsers which support it. Closes #11004. [cfis, Tobie Langel]
* Prevent Element#cumulativeOffset, Element#getOffsetParent, Element#positionedOffset, Element#viewportOffset and Element#clonePosition from throwing an error in IE when called on a parent-less element. Closes #9416, #10192, #10248. [ronstoney, psiborg, kangax]
* Prevent Enumerable#eachSlice from entering into an endless loop if passed an argument smaller than 1. Closes #10665. [kangax, Tobie Langel]

View File

@ -57,6 +57,7 @@ if (!Node.ELEMENT_NODE) {
return Element.writeAttribute(cache[tagName].cloneNode(false), attributes);
};
Object.extend(this.Element, element || { });
if (element) this.Element.prototype = element.prototype;
}).call(window);
Element.cache = { };

View File

@ -4,6 +4,9 @@
<head>
<title>Prototype Unit test file</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<script type="text/javascript" charset="utf-8">
var originalElement = Element;
</script>
<script src="../../dist/prototype.js" type="text/javascript"></script>
<script src="../lib/unittest.js" type="text/javascript"></script>
<link rel="stylesheet" href="../test.css" type="text/css" />
@ -1443,6 +1446,11 @@
assertEqual('my_input_field', $(document.body.lastChild).name);
if (Prototype.Browser.IE)
assertMatch(/name=["']?my_input_field["']?/, $('my_input_field').outerHTML);
if (originalElement && Prototype.BrowserFeatures.ElementExtensions) {
Element.prototype.fooBar = Prototype.emptyFunction
assertRespondsTo('fooBar', new Element('div'));
}
}},
testElementGetHeight: function() {with(this) {