Prototype: Fix Element.insert for null values and numeric values when defaulting to bottom
This commit is contained in:
parent
d4d4fddc7c
commit
5f4bab4dcb
14
src/dom.js
14
src/dom.js
|
@ -108,8 +108,9 @@ Element.Methods = {
|
|||
insert: function(element, insertions) {
|
||||
element = $(element);
|
||||
|
||||
if(typeof insertions == 'string' || insertions.ownerDocument === document)
|
||||
insertions = {bottom:insertions};
|
||||
if (typeof insertions == 'string' || typeof insertions == 'number' ||
|
||||
(insertions && insertions.ownerDocument === document))
|
||||
insertions = {bottom:insertions};
|
||||
|
||||
var content, t, range;
|
||||
|
||||
|
@ -123,7 +124,7 @@ Element.Methods = {
|
|||
continue;
|
||||
}
|
||||
|
||||
content = content.toString();
|
||||
content = String.interpret(content);
|
||||
|
||||
range = element.ownerDocument.createRange();
|
||||
t.initializeRange(element, range);
|
||||
|
@ -635,8 +636,9 @@ if (!document.createRange || Prototype.Browser.Opera) {
|
|||
Element.Methods.insert = function(element, insertions) {
|
||||
element = $(element);
|
||||
|
||||
if(typeof insertions == 'string' || insertions.ownerDocument === document)
|
||||
insertions = {bottom:insertions};
|
||||
if (typeof insertions == 'string' || typeof insertions == 'number' ||
|
||||
(insertions && insertions.ownerDocument === document))
|
||||
insertions = {bottom:insertions};
|
||||
|
||||
var t = Element._insertionTranslations, content, position, pos, tagName;
|
||||
|
||||
|
@ -650,7 +652,7 @@ if (!document.createRange || Prototype.Browser.Opera) {
|
|||
continue;
|
||||
}
|
||||
|
||||
content = content.toString();
|
||||
content = String.interpret(content);
|
||||
tagName = ((position == 'before' || position == 'after')
|
||||
? element.parentNode : element).tagName.toUpperCase();
|
||||
|
||||
|
|
|
@ -446,7 +446,14 @@
|
|||
assert(getInnerHTML('element-insertions-multiple-main').startsWith('1'));
|
||||
assert(getInnerHTML('element-insertions-multiple-main').endsWith('2'));
|
||||
assert(getInnerHTML('element-insertions-multiple-container').startsWith('<p>3</p>'));
|
||||
assert(getInnerHTML('element-insertions-multiple-container').endsWith('4'));
|
||||
assert(getInnerHTML('element-insertions-multiple-container').endsWith('4'));
|
||||
|
||||
$('element-insertions-main').update('test');
|
||||
$('element-insertions-main').insert(null);
|
||||
$('element-insertions-main').insert({bottom:null});
|
||||
assertEqual('test', getInnerHTML('element-insertions-main'));
|
||||
$('element-insertions-main').insert(1337);
|
||||
assertEqual('test1337', getInnerHTML('element-insertions-main'));
|
||||
}},
|
||||
|
||||
testInsertionBackwardsCompatibility: function() {with(this) {
|
||||
|
|
Loading…
Reference in New Issue