Skip to content

fix: negate missing condition paths correctly - #449

Open
Mohamed Mansour (mohamedmansour) wants to merge 1 commit into
microsoft:mainfrom
mohamedmansour:mohamedmansour-fix-missing-path-negation
Open

fix: negate missing condition paths correctly#449
Mohamed Mansour (mohamedmansour) wants to merge 1 commit into
microsoft:mainfrom
mohamedmansour:mohamedmansour-fix-missing-path-negation

Conversation

@mohamedmansour

Copy link
Copy Markdown
Contributor

A missing condition path currently propagates MissingValue until the handler converts the entire expression to false. That skips unary negation, so both path and !path render as false and SSR diverges from the existing browser evaluator.

Changes

  • Treat missing identifier leaves as falsy before applying negation and logical operators.
  • Preserve the existing missing-comparison error behavior and malformed-expression diagnostics.
  • Add parser-to-SSR and Playwright regressions for missing top-level and loop-item paths, including client-created and reactive repeat updates.
  • Clarify the missing-path contract in the design specification and authoring docs.

Compatibility

Direct microsoft-webui-expressions callers now receive Ok(false) instead of MissingValue for a missing bare identifier. This aligns the public evaluator with documented handler behavior and the compiled browser runtime. Missing comparison operands retain their prior error behavior.

Testing

  • cargo xtask check
  • cargo test -p microsoft-webui-expressions
  • Targeted microsoft-webui-handler SSR regression
  • pnpm typecheck:e2e in packages/webui-framework
  • Playwright repeat-conditional fixture suite
  • pnpm build in docs

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a condition-evaluation edge case where missing identifier paths incorrectly propagated MissingValue through evaluation, causing unary negation (!) to be skipped and making path and !path both evaluate as false. This brings SSR behavior back in line with the browser/runtime evaluator and the documented handler contract.

Changes:

  • Update microsoft-webui-expressions to treat missing identifier leaves as falsy operands (Ok(false)) while preserving missing-comparison-operand errors (MissingValue).
  • Add SSR + Playwright regression coverage for missing top-level and loop-item paths (including client-created elements and repeat updates).
  • Update DESIGN + docs to clearly specify the “missing identifier is falsy (and negation applies)” contract.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.

Show a summary per file
File Description
packages/webui-framework/tests/fixtures/repeat-conditional/src/test-repeat-conditional/test-repeat-conditional.html Adds missing top-level and loop-item <if> branches to exercise missing-path truthiness and negation.
packages/webui-framework/tests/fixtures/repeat-conditional/repeat-conditional.spec.ts Adds Playwright regression asserting missing identifiers are falsy and negation flips them, both SSR and client-created.
docs/guide/concepts/state-management/index.md Documents missing identifier behavior in conditions vs empty output for missing text/attr bindings.
docs/guide/concepts/how-it-works.md Clarifies SSR “source of truth” guidance while reflecting missing identifier falsy semantics.
docs/guide/concepts/directives/if.md Updates truthiness table and explicitly explains missing identifier behavior under negation.
docs/guide/concepts/best-practices.md Aligns best-practices guidance with updated missing-identifier condition semantics.
docs/ai/SKILL.md Updates AI guidance to match missing identifier falsy/negation semantics.
DESIGN.md Updates the spec to define missing identifier operands as falsy before negation/logicals, while preserving handler behavior for missing predicates.
crates/webui-handler/src/lib.rs Updates condition-eval docs and adds an SSR regression test covering global + loop scopes under negation.
crates/webui-expressions/src/lib.rs Implements missing-identifier-as-false behavior and updates unit tests accordingly.

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants