Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extra URL escaping in Firefox #289

Open
andreacampi opened this issue Jul 5, 2012 · 6 comments
Open

Extra URL escaping in Firefox #289

andreacampi opened this issue Jul 5, 2012 · 6 comments
Assignees
Labels
Milestone

Comments

@andreacampi
Copy link
Member

Replacing attributes in a URL with {{$ $}} is broken on Firefox (tested with Mac Firefox 13.0.1).
This results in the URL being passed through unchanged.

See for example examples/template-currentdocument/index.html
In this case, when I click to post on Twitter I get: Check out {{$title$}} at {{$url$}}"

Following with Firebug, it looks like innerHTML has started escaping the href attribute, at least in some case.

There is a bug open at https://bugzilla.mozilla.org/show_bug.cgi?id=664398 with no activity in the past year.

@andreacampi
Copy link
Member Author

This is not so much a bug in Treesaver as in Firefox, but it breaks social sharing buttons in Firefox so we must find a workaround.

@andreacampi
Copy link
Member Author

The workaround is to use data-href; it is copied through to href automatically, and Firefox doesn't exhibit the bug there.

@bramstein
Copy link
Member

So the problem is that when we use innerHTML to read a template one or more of {{$...$}} gets escaped by Firefox. This then result in Mustache.js not recognizing it?

@andreacampi
Copy link
Member Author

Yes, exactly.

@bramstein
Copy link
Member

Right:

>>> var a = document.createElement('div');
undefined
>>> a.innerHTML = '<a href="{{$something$}}">test</a>';
"<a href="{{$something$}}">test</a>"
>>> a.innerHTML
"<a href="%7B%7B$something$%7D%7D">test</a>"

I think that was exactly why we introduced the data-* attributes. I guess it should be documented better though.

@andreacampi
Copy link
Member Author

Yeah, and most of all, the examples should be updated.

@ghost ghost assigned andreacampi Oct 20, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants