Skip to content

Commit

Permalink
Fixes liferay#1393 If data-style attribute is not a valid JSON a exce…
Browse files Browse the repository at this point in the history
…ption will be thrown and the code will stop working
  • Loading branch information
georgel-pop-lr committed May 18, 2020
1 parent 8404706 commit a1c1452
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/plugins/embedurl.js
Original file line number Diff line number Diff line change
Expand Up @@ -406,11 +406,19 @@ if (!CKEDITOR.plugins.get('embedurl')) {

// Sync dimensions and alignment with editor wrapper

let styles = null;

const stylesJSON = instance.element.getAttribute(
'data-styles'
);

let styles = stylesJSON ? JSON.parse(stylesJSON) : null;
if (stylesJSON) {
try {
styles = JSON.parse(stylesJSON);
} catch (e) {
console.warn('Unable to parse data-styles attribute!');
}
}

if (!styles) {
const iframe = instance.wrapper.findOne('iframe');
Expand Down

0 comments on commit a1c1452

Please sign in to comment.