mirror of
https://github.com/wassname/talk.git
synced 2026-07-31 12:50:48 +08:00
Better disabled detection
This commit is contained in:
@@ -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
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user