This is very similar to [#10165], but I'm seeing it in Drupal 7. I looked at the patch offered in [#10165], but the gotwo.module is pretty different for Drupal 7.

See http://drupal.org/node/101605

My "gotwo" link is:

<go href="http://rickumali.com"><img src="http://www.beginnericehockey.com/sites/default/files/hockey-logo-sm.gif"></go>

I'm willing to take up the fix, but if someone could corroborate this, or tell me what I'm doing wrong, that'd be great. Thank you!

Comments

rickumali’s picture

My description was messed up. I meant to write that this is similar to #101605: <img> inside <go> appears to break it.. Thank you!

rickumali’s picture

I have a fix that seems to work for me, but I'd love a code review of sorts. The diff is:

> diff gotwo.module.orig gotwo.module
200c200,204
<     $linkNode = $goNode->ownerDocument->createElement('a', $goNode->nodeValue);
---
>     // This is a fix for http://drupal.org/node/1088042
>     // Assumes that <go> tag only contains ONE CHILD
>     $firstChild = $goNode->firstChild;
>     $linkNode = $goNode->ownerDocument->createElement('a');
>     $linkNode->appendChild($firstChild);
417c421
< }
\ No newline at end of file
---
> }

Basically, when <go> contains an <img>, the goNode->nodeValue is an empty string (or at least, it acts empty). This is because the nodeValue is not a TEXT_NODE, but rather an ELEMENT_NODE. The proposed fix creates the element 'a' as the linkNode, and then appends the first child into it. Big assumption is that will contain ONE CHILD. The fix could be made more defensive. Please advise on checking in and what not.

Summit’s picture

Subscribing, greetings, Martijn

hass’s picture

Title: Child elements of a GO link are not cloned » IMG inside of GO Does Not Display IMG (D7)
Status: Fixed » Active

Maybe we are able to clone all stuff inside an A tag... I cannot remember why or if I have tested the IMG inside an A tag. We should write a .test to prevent future failures.

hass’s picture

Title: IMG inside of GO Does Not Display IMG (D7) » Child elements of a GO link are not cloned
Status: Active » Fixed

Committed a fix (http://drupalcode.org/project/gotwo.git/commit/72b7e1e) that clones all child nodes and not only the first child.

Please give next DEV a try an report back if it works for you. We still need to write tests for this...

Title: IMG inside of GO Does Not Display IMG (D7) » Child elements of a GO link are not cloned
Status: Active » Closed (fixed)

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