Skip to main content

Bug Tracker

Side navigation

#7731 closed bug (invalid)

Opened December 08, 2010 10:04PM UTC

Closed December 08, 2010 10:53PM UTC

Uncaught TypeError: Object #<an Object> has no method 'replace'

Reported by: FamLam <fam.lam@live.nl> Owned by: FamLam <fam.lam@live.nl>
Priority: undecided Milestone: 1.6
Component: unfiled Version: 1.4.4
Keywords: Cc:
Blocked by: Blocking:
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)
Attachments (0)
Change History (2)

Changed December 08, 2010 10:30PM UTC by rwaldron comment:1

owner: → FamLam <fam.lam@live.nl>
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.

Changed December 08, 2010 10:53PM UTC by jitter comment:2

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