Ticket #7731 (closed bug: invalid)
Uncaught TypeError: Object #<an Object> has no method 'replace'
| Reported by: | FamLam <fam.lam@…> | Owned by: | FamLam <fam.lam@…> |
|---|---|---|---|
| Priority: | undecided | Milestone: | 1.6 |
| Component: | unfiled | Version: | 1.4.4 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
Uncaught TypeError: Object #<an Object> has no method 'replace' in line 101 of the minimized version of JQuery 1.4.4
<html>
<head>
<script src="http://code.jquery.com/jquery-1.4.4.min.js" type="text/javascript"></script>
<script>
function removeFrame(el) {
var parentEl = $(el).parent();
var cols = (parentEl.attr('cols').indexOf(',') > 0);
if (!cols && parentEl.attr('rows').indexOf(',') <= 0)
return;
cols = (cols ? 'cols' : 'rows');
var sizes = parentEl.attr(cols).split(',');
sizes[$(el).prevUntil(parentEl).length] = 0;
parentEl.attr(cols, sizes.join(','));
}
beforeLoadHandler = function(event) {
var el = event.target;
event.preventDefault();
if (el.nodeName == "FRAME")
removeFrame(el);
}
document.addEventListener("beforeload", beforeLoadHandler, true);
</script>
</head>
<frameset rows="50%,75" border="0" framespacing="0">
<frame name="destframe" src="http://www.google.com/" marginwidth="0" marginheight="0" scrolling="auto" frameborder="0">
<frame src="http://www.jquery.com/" name="bottom" frameborder="0" scrolling="NO" marginwidth="0" marginheight="0" noresize="">
</frameset>
</html>
This worked fine in 1.4.2 AFAIK
Browser: Chrome
The error occurs in this part of the code:
$(el).prevUntil(parentEl)
Change History
comment:1 Changed 2 years ago by rwaldron
- Owner set to FamLam <fam.lam@…>
- Status changed from new to pending
comment:2 Changed 2 years ago by jitter
- Status changed from pending to closed
- Resolution set to invalid
This isn't a jQuery bug. Your usage of .prevUntil(selector) is invalid. The documentation says:
prevUntil( [ selector ] )
selector A string containing a selector expression to indicate where to stop matching preceding sibling elements.
But you are passing in parentEl which is a jQuery object and not a string. That you didn't get an exception with 1.4.2 was just by chance
Btw. I don't understand why you even do $(el).prevUntil(parentEl).
prevUntil(selector) returns all siblings up to but not including the element matched by the selector. As parentEl is the parent of el (excluding the fact that parentEl isn't a string) this would never match as a parent can't be a sibling. So you can just replace this expression with $(el).prevAll().
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

Thanks for taking the time to contribute to the jQuery project! Please provide a reduced jsFiddle test case to help us assess your ticket!
Additionally, test against the latest jQuery release AND the jQuery 0 GIT version to ensure the issue still exists. Be Excellent to eachother!
Lastly, I attempted to recreate your issue from the code above and was unable to produce an error.