Skip to content

Commit

Permalink
Content checks for text expression
Browse files Browse the repository at this point in the history
  • Loading branch information
kachurun committed Oct 21, 2024
1 parent 4c4ec88 commit 161cb1c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
7 changes: 5 additions & 2 deletions src/expressions/text.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@ export const getTextNode = (node, childNodeIndex) => {
/**
* This methods handles a simple text expression update
* @param {Object} expression - expression object
* @param {HTMLElement} expression.node - target node
* @param {Text} expression.node - target node
* @param {*} value - new expression value
* @returns {undefined}
*/
export default function textExpression({ node }, value) {
node.data = normalizeStringValue(value)
const text = normalizeStringValue(value)
if (node.data !== text) {
node.data = normalizeStringValue(value)
}
}
6 changes: 2 additions & 4 deletions src/util/normalize-string-value.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { isNil } from '@riotjs/util/checks'

/**
* Normalize the user value in order to render a empty string in case of falsy values
* Normalize the user value in order to render an empty string in case of falsy values
* @param {*} value - user input value
* @returns {string} hopefully a string
*/
export default function normalizeStringValue(value) {
return isNil(value) ? '' : value
return value == null ? '' : value
}

0 comments on commit 161cb1c

Please sign in to comment.