-
Notifications
You must be signed in to change notification settings - Fork 776
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: don't be so greedy in virtual checks with try/catch (#2719)
- Loading branch information
Showing
4 changed files
with
64 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,33 @@ | ||
import visibleVirtual from '../../commons/text/visible-virtual'; | ||
|
||
function svgNonEmptyTitleEvaluate(node, options, virtualNode) { | ||
try { | ||
const titleNode = virtualNode.children.find(({ props }) => { | ||
return props.nodeName === 'title'; | ||
}); | ||
if (!virtualNode.children) { | ||
return undefined; | ||
} | ||
|
||
if (!titleNode) { | ||
this.data({ | ||
messageKey: 'noTitle' | ||
}); | ||
return false; | ||
} | ||
const titleNode = virtualNode.children.find(({ props }) => { | ||
return props.nodeName === 'title'; | ||
}); | ||
|
||
if (!titleNode) { | ||
this.data({ | ||
messageKey: 'noTitle' | ||
}); | ||
return false; | ||
} | ||
|
||
try { | ||
if (visibleVirtual(titleNode) === '') { | ||
this.data({ | ||
messageKey: 'emptyTitle' | ||
}); | ||
return false; | ||
} | ||
|
||
return true; | ||
} catch (e) { | ||
return undefined; | ||
} | ||
|
||
return true; | ||
} | ||
|
||
export default svgNonEmptyTitleEvaluate; |