Skip to content

Commit 83e6ef2

Browse files
committed
Chore: Make observe changes logic easier to read
1 parent 6abcb32 commit 83e6ef2

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/behaviors/attach/attach.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -542,11 +542,15 @@ const events = {
542542
};
543543

544544
const mutations = {
545-
'attributes'({ attributeName, attributeValue, settings, self }) {
546-
if (!settings.observeChanges === true || !attributeName === 'style' || !attributeValue.includes('display')) {
547-
return;
545+
'attributes'({ attributeName, attributeValue = '', settings, self }) {
546+
if (settings.observeChanges) {
547+
// only obverve changes that cause layout changes
548+
const styleChanged = attributeName == 'style';
549+
const displayChanged = attributeValue.includes('display');
550+
if (styleChanged && displayChanged) {
551+
self.reposition();
552+
}
548553
}
549-
self.reposition();
550554
},
551555
};
552556

0 commit comments

Comments
 (0)