Intra-post anchor links don't work in Safari / Firefox


(Paul Kaplan) #1

I’ve been experimenting with anchor links inside of posts (links to content inside of a long post). I have read that you can’t use the ids because they get stripped. I used the name property instead and it works for Chrome but throws a very cryptic error in Safari.

Error: Syntax error, unrecognized expression: [name=anchor-name

It doesn’t give a useful trace so I can’t even tell where it is coming from. Is the anchor routing dealt with by Ember? Is there custom logic for that somewhere?

Example 1 (Live bug)

Try going to this link in Chrome (it works) but in Safari it throws an error and doesn’t work:

Example 2 (Reproduced bug)

works in Chrome, throws errors in safari

Table of contents

Topic 1

The markup for this heading is:

#### <a name="topic-1">Topic 1</a>

Topic 2

The markup for this heading is:

#### <a name="topic-2">Topic 2</a>

TOC Markup

The markup for the table of contents is

### Table of contents
- <a href="#topic-1">Topic 1</a>
- <a href="#topic-2">Topic 2</a>
- <a href="#toc-markup">TOC markup</a>

Status of anchor link bug

I can repro this on Firefox v38

(Paul Kaplan) #3

Plot like gravy thickens. It appears to not throw any errors in development mode, only in production…

(Sam Saffron) #4

Can be minifier related , seen a minifier bug once before

(Paul Kaplan) #5

Can you point me to where in the JS this is being handled?

(Sam Saffron) #6

It is here

(Paul Kaplan) #7

I’m sorry I should have been more specific, I meant where was the name anchor code happening. I dove in and found it in javascripts/discourse/lib/url.js. It looks like there is a missing bracket.

Not sure why that would break only production though…

I’ll submit a PR.

(Paul Kaplan) #8

PR submitted

(Régis Hanol) #9