diff --git a/src/commands/view/SelectComponent.js b/src/commands/view/SelectComponent.js index a7a5a1831..0d2b238ee 100644 --- a/src/commands/view/SelectComponent.js +++ b/src/commands/view/SelectComponent.js @@ -1,5 +1,5 @@ import { bindAll, isElement, isUndefined } from 'underscore'; -import { on, off, getUnitFromValue, isTextNode } from 'utils/mixins'; +import { on, off, getUnitFromValue, isTaggableNode } from 'utils/mixins'; const ToolbarView = require('dom_components/view/ToolbarView'); const Toolbar = require('dom_components/model/Toolbar'); @@ -355,10 +355,9 @@ module.exports = { const editor = em ? em.get('Editor') : ''; const config = em ? em.get('Config') : ''; const pfx = config.stylePrefix || ''; - const attrName = `data-${pfx}handler`; const resizeClass = `${pfx}resizing`; const model = - !isElement(elem) && !isTextNode(elem) ? elem : em.getSelected(); + !isElement(elem) && isTaggableNode(elem) ? elem : em.getSelected(); const resizable = model.get('resizable'); const el = isElement(elem) ? elem : model.getEl(); let options = {}; diff --git a/src/style_manager/view/SectorsView.js b/src/style_manager/view/SectorsView.js index e242889ec..2253b5883 100644 --- a/src/style_manager/view/SectorsView.js +++ b/src/style_manager/view/SectorsView.js @@ -1,6 +1,6 @@ import Backbone from 'backbone'; import { extend, isString } from 'underscore'; -import { isTextNode } from 'utils/mixins'; +import { isTaggableNode } from 'utils/mixins'; const SectorView = require('./SectorView'); @@ -55,7 +55,7 @@ module.exports = Backbone.View.extend({ pt.helper = null; // Create computed style container - if (el && !isTextNode(el)) { + if (el && isTaggableNode(el)) { const stateStr = state ? `:${state}` : null; pt.computed = window.getComputedStyle(el, stateStr); } diff --git a/src/utils/mixins.js b/src/utils/mixins.js index 63e533936..28853dade 100644 --- a/src/utils/mixins.js +++ b/src/utils/mixins.js @@ -117,6 +117,20 @@ const getElement = el => { */ const isTextNode = el => el && el.nodeType === 3; +/** + * Check if element is a comment node + * @param {HTMLElement} el + * @return {Boolean} + */ +export const isCommentNode = el => el && el.nodeType === 8; + +/** + * Check if element is a comment node + * @param {HTMLElement} el + * @return {Boolean} + */ +export const isTaggableNode = el => el && !isTextNode(el) && !isCommentNode(el); + /** * Ensure to fetch the model from the input argument * @param {HTMLElement|Component} el Component or HTML element