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

Allow proper indenting/nesting of img tag within anchor #1

Closed
t1merickson opened this issue Jun 26, 2014 · 3 comments
Closed

Allow proper indenting/nesting of img tag within anchor #1

t1merickson opened this issue Jun 26, 2014 · 3 comments

Comments

@t1merickson
Copy link

This is valid:

<a class="fancy" href="image-big.jpg"><img src="image-thumb.jpg" /></a>

This is not, but I'd like it to be :)

<a class="fancy" href="image-big.jpg">
    <img src="image-thumb.jpg" />
</a>
@keegnotrub
Copy link
Owner

I wonder if its related to this line.

Like I wonder what would happen if I just changed that part of the method from:

  if (elemFind.childNodes.length > 0) {
    elemFind = elemFind.childNodes[0];
  }

  var $elemFind = $(elemFind);

to

  var $elemFind = $(elemFind);

  if ($elemFind.children().length > 0) {
    $elemFind = $elemFind.children(":first");
  }

@leighmarble
Copy link
Contributor

After struggling with figuring out why fancyzoom wasn't working on my system, I found this issue. I would have never guessed that a whitespace issue was the cause, but after trying my <img> inside the anchor without any spaces or newlines, as @neutyp shows above, that got it to work.

Then I tried the code change @keegnotrub guesses about, and that worked as well (and I was able to put newlines and whitespace back between <a> and <img>.

I'll fork the code and make this change, since no one else has.

leighmarble added a commit to leighmarble/jquery.fancyzoom that referenced this issue Feb 10, 2015
Just implementing the idea that `keegnotrub` suggests here, because it worked for me to fix an otherwise broken fancyzoom:

keegnotrub#1

However, I can't vouch for this being the best solution, so someone else who knows Javascript better should vet this.
@keegnotrub
Copy link
Owner

Fixed - thanks @leighmarble for the pull request!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants