* @param {string} val * @param {string} tagName * @param {string|Matcher} jPath - jPath string or Matcher instance based on options.jPath * @param {boolean} dontTrim * @param {boolean} hasAttributes * @param {boolean} isLeafNode * @param {boolean} escapeEntities
(val, tagName, jPath, dontTrim, hasAttributes, isLeafNode, escapeEntities)
| 148 | * @param {boolean} escapeEntities |
| 149 | */ |
| 150 | function parseTextData(val, tagName, jPath, dontTrim, hasAttributes, isLeafNode, escapeEntities) { |
| 151 | const options = this.options; |
| 152 | if (val !== undefined) { |
| 153 | if (options.trimValues && !dontTrim) { |
| 154 | val = val.trim(); |
| 155 | } |
| 156 | if (val.length > 0) { |
| 157 | if (!escapeEntities) val = this.replaceEntitiesValue(val, tagName, jPath); |
| 158 | |
| 159 | // Pass jPath string or matcher based on options.jPath setting |
| 160 | const jPathOrMatcher = options.jPath ? jPath.toString() : jPath; |
| 161 | const newval = options.tagValueProcessor(tagName, val, jPathOrMatcher, hasAttributes, isLeafNode); |
| 162 | if (newval === null || newval === undefined) { |
| 163 | //don't parse |
| 164 | return val; |
| 165 | } else if (typeof newval !== typeof val || newval !== val) { |
| 166 | //overwrite |
| 167 | return newval; |
| 168 | } else if (options.trimValues) { |
| 169 | return parseValue(val, options.parseTagValue, options.numberParseOptions); |
| 170 | } else { |
| 171 | const trimmedVal = val.trim(); |
| 172 | if (trimmedVal === val) { |
| 173 | return parseValue(val, options.parseTagValue, options.numberParseOptions); |
| 174 | } else { |
| 175 | return val; |
| 176 | } |
| 177 | } |
| 178 | } |
| 179 | } |
| 180 | } |
| 181 | |
| 182 | function resolveNameSpace(tagname) { |
| 183 | if (this.options.removeNSPrefix) { |
nothing calls this directly
no test coverage detected