image2: throws an exception if set a content with an empty figure tag #2506
Labels
good first issue
Relatively easy to fix. This is a perfect issue if you are willing to create a Pull Request.
plugin:image2
The plugin which probably causes the issue.
status:confirmed
An issue confirmed by the development team.
target:minor
Any docs related issue that can be merged into a master or major branch.
type:bug
A bug.
Milestone
Type of report
Bug
Provide detailed reproduction steps (if any)
config.extraPlugins = 'image2'
;<figure class="image"></figure>
image2 plugin throws an exception if ckeditor's content contains empty "figure" tag (or if a "figure" does not contains nor "img" nor "a" tag).
image2 expects that "figure" must always contains "img" tag or "a" tag that contains "img".
image = el.getFirst( 'img' ) || el.getFirst( 'a' ).getFirst( 'img' );
The issue can be reloved by adding additional checking:
image = el.getFirst( 'img' ) || (el.getFirst( 'a' ) && el.getFirst( 'a' ).getFirst( 'img' ));
Expected result
Exception should not be thrown.
Actual result
Uncaught TypeError: Cannot read property 'getFirst' of null
exception is being thrown.Other details
The text was updated successfully, but these errors were encountered: