Updated to Bootstrap 3.4 and now dropdown's have stopped working. This happens with both Jquery 1.9 and 1.10.

The error is: Error: Syntax error, unrecognized expression: #

It appears to be stemming from this code in dropdown.js:

function getParent($this) {
    var selector = $this.attr('data-target')

    if (!selector) {
      selector = $this.attr('href')
      selector = selector && /#[A-Za-z]/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7
    }

    var $parent = selector && $(document).find(selector)

    return $parent && $parent.length ? $parent : $this.parent()
  }
CommentFileSizeAuthor
#3 3021341-3.patch1.01 KBmarkhalliwell

Comments

rschwab created an issue. See original summary.

rschwab’s picture

This might actually be a bug in Bootstrap 3.4. Maybe the documentation just needs to be updated? See https://github.com/twbs/bootstrap/issues/27869

markhalliwell’s picture

Title: Bootstrap 3.4 breaks dropdown menus » Syntax error, unrecognized expression: #
Version: 7.x-3.22 » 7.x-3.x-dev
Status: Active » Fixed
Related issues: +#2903656: Updating to Drupal core 8.4.0-beta1 results in not working dropdown menu
StatusFileSize
new1.01 KB

This is partially a framework issue (because they really should handle hashes properly), but was more of an issue introduced with higher jQuery versions. This was already "fixed" upstream in 8.x-3.x; needs a backport.

  • markcarver committed d83c7c3 on 7.x-3.x
    Issue #3021341 by markcarver, rschwab: Syntax error, unrecognized...
rschwab’s picture

Over at GitHub Johann-S suggested this change in dropdown.js:

From:
var $parent = selector && $(document).find(selector)

To:
var $parent = selector !== '#' && $(document).find(selector)

I've tested and it works, but I'm not familiar enough with the underlying XSS issue to understand if its preferable to the patch above, or not.

At any rate thanks for the very fast response, and the great theme!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

afsolano’s picture

The patch isn't working for me. With theme version 3.23 and jquery 2.1 the error continues to happen.