Permalink
Browse files

Merge branch 'master' of git@github.com:sstephenson/prototype

  • Loading branch information...
2 parents 32bc695 + 71a8663 commit 3fa20a198b0d86e45023a571232d3a91e0467f28 @savetheclocktower savetheclocktower committed Mar 23, 2009
Showing with 33 additions and 1 deletion.
  1. +2 −0 CHANGELOG
  2. +22 −1 src/dom/dom.js
  3. +9 −0 test/unit/dom_test.js
View
@@ -1,5 +1,7 @@
*1.6.1_rc1* (March 22, 2009)
+* `Element#update` now takes care of SCRIPT elements in IE. [#573 state:resolved] (Martin, Tobie Langel, kangax)
+
* Remove unused local variables from `Element.extend`. Fix one of the form tests to remove `_extendedByPrototype` by setting it to `undefined` rather than `false` (`_extendedByPrototype` being `false` does not force `Element.extend` to re-extend element). (T.J. Crowder, kangax)
* Make test for `escapeHTML`/`unescapeHTML` more strict. (Chrome 1.x escapes "<" and "&" with `innerHTML`, but not ">") (kangax)
View
@@ -203,6 +203,20 @@ Element.Methods = {
}
})();
+ var SCRIPT_ELEMENT_REJECTS_TEXTNODE_APPENDING = (function () {
+ var s = document.createElement("script"),
+ isBuggy = false;
+ try {
+ s.appendChild(document.createTextNode(""));
+ isBuggy = !s.firstChild ||
+ s.firstChild && s.firstChild.nodeType !== 3;
+ } catch (e) {
+ isBuggy = true;
+ }
+ s = null;
+ return isBuggy;
+ })();
+
function update(element, content) {
element = $(element);
@@ -213,9 +227,16 @@ Element.Methods = {
return element.update().insert(content);
content = Object.toHTML(content);
+
+ var tagName = element.tagName.toUpperCase();
+
+ if (tagName === 'SCRIPT' && SCRIPT_ELEMENT_REJECTS_TEXTNODE_APPENDING) {
+ // scripts are not evaluated when updating SCRIPT element
+ element.text = content;
+ return element;
+ }
if (SELECT_ELEMENT_INNERHTML_BUGGY || TABLE_ELEMENT_INNERHTML_BUGGY) {
- var tagName = element.tagName.toUpperCase();
if (tagName in Element._insertionTranslations.tags) {
$A(element.childNodes).each(function(node) {
element.removeChild(node);
View
@@ -378,6 +378,15 @@ new Test.Unit.Runner({
this.assertEqual('hello world', getInnerHTML('testdiv'));
},
+ testElementUpdateScriptElement: function() {
+ var el = new Element('script', {
+ type: 'text/javascript'
+ });
+ this.assertNothingRaised(function(){
+ el.update('(function(){})');
+ })
+ },
+
testElementReplace: function() {
$('testdiv-replace-1').replace('hello from div!');
this.assertEqual('hello from div!', $('testdiv-replace-container-1').innerHTML);

0 comments on commit 3fa20a1

Please sign in to comment.