Better disabled detection

This commit is contained in:
Chi Vinh Le
2018-03-26 22:44:24 +02:00
parent 5b9d24a029
commit dca9b19240
2 changed files with 6 additions and 4 deletions
@@ -1,5 +1,5 @@
import createToggle from '../factories/createToggle';
import { findIntersecting } from '../lib/dom';
import { findIntersecting, findAncestor } from '../lib/dom';
const boldTags = ['B', 'STRONG'];
@@ -21,7 +21,8 @@ function isDisabled() {
n =>
n.nodeName !== '#text' &&
window.getComputedStyle(n).getPropertyValue('font-weight') === 'bold' &&
!boldTags.includes(n.tagName),
!boldTags.includes(n.tagName) &&
!findAncestor(n, n => boldTags.includes(n.tagName), this.container),
this.container
);
}
@@ -1,5 +1,5 @@
import createToggle from '../factories/createToggle';
import { findIntersecting } from '../lib/dom';
import { findIntersecting, findAncestor } from '../lib/dom';
const italicTags = ['I', 'EM'];
@@ -19,7 +19,8 @@ function isDisabled() {
n =>
n.nodeName !== '#text' &&
window.getComputedStyle(n).getPropertyValue('font-style') === 'italic' &&
!italicTags.includes(n.tagName),
!italicTags.includes(n.tagName) &&
!findAncestor(n, n => italicTags.includes(n.tagName), this.container),
this.container
);
}