Problem
processAttr(undefined, defaultValue) returns defaultValue via identity (return defaultValue), but if a feature author passes NaN as the default, downstream comparisons like result === expected will always be false because NaN !== NaN in JavaScript.
This was discovered via a property test that generated NaN as a default value. While feature authors don't currently pass NaN, the function has no guard against it.
Options
- Document that
NaN is not a supported default — cheapest, matches current reality
- Normalize
NaN to undefined or null — defensive, prevents subtle bugs if a config accidentally produces NaN (e.g. parseInt('abc'))
- No change needed — if the type system (
ConfigSetting) already prevents this
Context
Found in PR #2261. The property test was narrowed to realistic defaults as a workaround.
// src/utils.js — processAttr
if (configSetting === undefined) {
return defaultValue; // if defaultValue is NaN, callers can't compare the result
}
Problem
processAttr(undefined, defaultValue)returnsdefaultValuevia identity (return defaultValue), but if a feature author passesNaNas the default, downstream comparisons likeresult === expectedwill always be false becauseNaN !== NaNin JavaScript.This was discovered via a property test that generated
NaNas a default value. While feature authors don't currently passNaN, the function has no guard against it.Options
NaNis not a supported default — cheapest, matches current realityNaNtoundefinedornull— defensive, prevents subtle bugs if a config accidentally producesNaN(e.g.parseInt('abc'))ConfigSetting) already prevents thisContext
Found in PR #2261. The property test was narrowed to realistic defaults as a workaround.