Bug Tracker

Opened 13 years ago

Closed 13 years ago

#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:
Blocked by: Blocking:


Uncaught TypeError: Object #<an Object> has no method 'replace' in line 101 of the minimized version of JQuery 1.4.4

    <script src="http://code.jquery.com/jquery-1.4.4.min.js" type="text/javascript"></script>
      function removeFrame(el) {
        var parentEl = $(el).parent();
        var cols = (parentEl.attr('cols').indexOf(',') > 0);
        if (!cols && parentEl.attr('rows').indexOf(',') <= 0)
        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;
        if (el.nodeName == "FRAME")

      document.addEventListener("beforeload", beforeLoadHandler, true);
  <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="">

This worked fine in 1.4.2 AFAIK
Browser: Chrome

The error occurs in this part of the code:


Change History (2)

comment:1 Changed 13 years ago by Rick Waldron

Owner: set to FamLam <fam.lam@…>
Status: newpending

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.

comment:2 Changed 13 years ago by jitter

Resolution: invalid
Status: pendingclosed

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().

Note: See TracTickets for help on using tickets.