Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(attr): treat empty string as no binding #1930

Merged
merged 8 commits into from
Mar 26, 2024
Merged

Conversation

bigopon
Copy link
Member

@bigopon bigopon commented Mar 25, 2024

📖 Description

Currently, custom attributes with single value binding have a weirdness in their usage related to empty string, or no value usage. Consider the following template:

<div my-attr>

There is ambiguity between no-value and empty string as value for the primary bindable.
Current behavior is we are assuming attribute wants to have an empty string but this is not ideal.

BREAKING CHANGE:

This PR changes the default behavior when there's no value (<div attr>), or an empty string value (<div attr="">) for a custom attribute usage, so that now there will be no binding created for the primary bindable. Applications that truely want to bind to an empty string can always use empty string expression like the following example:

<div my-attr.bind="">
<div my-attr.bind="``">

🎫 Issues

resolves #1911

cc @Sayan751 @fkleuver

Copy link

codecov bot commented Mar 25, 2024

Codecov Report

Attention: Patch coverage is 92.30769% with 3 lines in your changes are missing coverage. Please review.

Project coverage is 88.62%. Comparing base (49e327e) to head (c469d57).
Report is 2 commits behind head on master.

Files Patch % Lines
packages/runtime-html/src/templating/styles.ts 66.66% 1 Missing ⚠️
packages/runtime/src/binding/ast.visitor.ts 0.00% 1 Missing ⚠️
packages/state/src/state-templating.ts 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1930      +/-   ##
==========================================
+ Coverage   88.58%   88.62%   +0.04%     
==========================================
  Files         262      262              
  Lines       22870    22891      +21     
  Branches     5282     5288       +6     
==========================================
+ Hits        20260    20288      +28     
+ Misses       2610     2603       -7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@bigopon bigopon merged commit 8fc5275 into master Mar 26, 2024
26 checks passed
@bigopon bigopon deleted the feat/shadow-css branch March 26, 2024 12:37
AureliaEffect pushed a commit that referenced this pull request Apr 3, 2024
2.0.0-beta.14 (2024-04-03)

**Features:**

* **custom-attribute:** ability to find closest attr by name or ctor (#1928) ([ab28585](ab28585))
* **i18n:** support multiple versions of i18next (#1927) ([0789ee5](0789ee5))

**Bug Fixes:**

* **enhance:** dont call app tasks from parent container (#1933) ([e7119ec](e7119ec))
* **form:** prevent actionless submission (#1931) ([1fc74d4](1fc74d4))

**Refactorings:**

* **attr:** treat empty string as no binding (#1930) ([8fc5275](8fc5275))
AureliaEffect pushed a commit that referenced this pull request Apr 3, 2024
2.0.0-beta.14 (2024-04-03)

**Features:**

* **custom-attribute:** ability to find closest attr by name or ctor (#1928) ([ab28585](ab28585))
* **i18n:** support multiple versions of i18next (#1927) ([0789ee5](0789ee5))

**Bug Fixes:**

* **enhance:** dont call app tasks from parent container (#1933) ([e7119ec](e7119ec))
* **form:** prevent actionless submission (#1931) ([1fc74d4](1fc74d4))

**Refactorings:**

* **attr:** treat empty string as no binding (#1930) ([8fc5275](8fc5275))
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.

Restrict behavior of custom attribute single value binding and primary bindable
1 participant