Skip to content

Commit

Permalink
fix: gracefully handle invalid JSON in data-style attribute (liferay#…
Browse files Browse the repository at this point in the history
  • Loading branch information
georgel-pop-lr committed May 18, 2020
1 parent 8404706 commit 31719be
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/plugins/embedurl.js
Original file line number Diff line number Diff line change
Expand Up @@ -406,11 +406,21 @@ 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 31719be

Please sign in to comment.