Opened 5 years ago

Closed 5 years ago

#11783 closed Bug (fixed)

Link in image caption is taken as link which wraps image

Reported by: Piotrek Koszuliński Owned by: Olek Nowodziński
Priority: Normal Milestone: CKEditor 4.4.0
Component: General Version: 4.4.0
Keywords: Drupal Cc: wim.leers@…

Description

In image2 sample load:

<figure class="image"><img alt="Saturn V" src="assets/image1.jpg" width="200" />
<figcaption>Roll out <a href="x">of Saturn V</a> on launch pad</figcaption>
</figure>

Kaboom! The issue is caused by widget.parts.link discovering the link inside figcaption.

Change History (5)

comment:1 Changed 5 years ago by Piotrek Koszuliński

Status: newconfirmed

comment:2 Changed 5 years ago by Wim Leers

Cc: wim.leers@… added
Keywords: Drupal added

I found and reported this.

And I think I've found the solution.

In the image2 plugin's widget definition:

			parts: {
				image: 'img',
				caption: 'figcaption',
				link: 'a'
			},

The widget plugin's setupParts() function calls

widget.wrapper.findOne( widget.parts[ partName ] );

This selects any a element inside the widget. Which causes the wrong a to be selected: the one in the caption.

So the solution is super simple: just update the selector!

			parts: {
				image: 'img',
				caption: 'figcaption',
				link: 'figure a'
			},
Version 0, edited 5 years ago by Wim Leers (next)

comment:3 Changed 5 years ago by Olek Nowodziński

Owner: set to Olek Nowodziński
Status: confirmedreview

It could be solved with the following selector if IE8 supported :not():

link: 'a[data-widget],*:not(figcaption)>a'

But it does not. Fix pushed to branch:t/11783 (tests).

comment:4 in reply to:  3 Changed 5 years ago by Olek Nowodziński

Replying to a.nowodzinski:

It could be solved with the following selector if IE8 supported :not():

link: 'a[data-widget],*:not(figcaption)>a'

But it does not. Fix pushed to branch:t/11783 (+tests).

comment:5 Changed 5 years ago by Piotrek Koszuliński

Resolution: fixed
Status: reviewclosed

Thanks. R+, merged to major with git:e20ae7b on dev and 2a75dd9 on tests.

Note: See TracTickets for help on using tickets.
© 2003 – 2019 CKSource – Frederico Knabben. All rights reserved. | Terms of use | Privacy policy