Comments (10)
The looser comparison seems like it might be the way to go, rather than coercing values.
from aurelia.
Can you elaborate?
You mean a == b
instead of (a+'') === b
or?
from aurelia.
I meant this value === true || value === 'true'
. Or is this two separate issues?
from aurelia.
Yeah it's two separate ones. (a, b) => a === b
is the default matcher function for radio input collections and checked arrays. value === true
is for single primitive values
The primitive only responds to boolean at the moment. But since checked
only responds to boolean, coercion numbers wouldn't make sense anyway, hence the || value === 'true'
The array is a bit broader because it simply looks for equality with the .value
attribute, hence the a+''
from aurelia.
We should get @jdanyow to provide feedback on this. I thought the model
properties we set up handled keeping the original types. It was a long time ago that we addressed this issue though.
from aurelia.
Yep just ran into this with the unit tests. The model property doesn't have this problem so I would only apply the coercion logic for the value
attribute. I've always seen the model as a way to support objects, not necessarily for the coercion.
It's possible to solve the coercion with model, but letting that be the only way seems counter-intuitive.
For example:
input.value = 42;
input.value === 42; // false - would become true
input.value = '42';
input.value === 42; // false - would become true
input.value = 42;
input.value === '42'; // true - stays true
input.value = 'true';
input.value === true; // false - would become true
etc..
from aurelia.
Just walked through the comments, I'm not sure how to look at this. Though altering behavior of input.value
could be nice, I don't think it's a good idea as it's no longer predictable. That's for our core implementation. In the future, we can allow observer locator to be override-able / extendable and can experiment with all these maybe intuitive behaviors.
from aurelia.
It's the other way around. Currently it's not predictable because the DOM will coerce values but the observer won't. I'm simply suggesting we should make the observer do the same coercions that the DOM does, so that it becomes predictable :)
from aurelia.
Is there any reason we have to use the input.value
property for these comparisons? Couldn't we handle all cases the same way we handle model.bind
?
from aurelia.
Implicitly converting the value types could be double edged, we better wait until the first request comes to have some concrete case based ideas.
from aurelia.
Related Issues (20)
- HTML attribute removed on binding/templating HOT 4
- Inconsistencies in Router Documentation HOT 1
- a load is completely broken - AUR0707:route,load HOT 20
- Replace sass-lint to get rid of critical vulnerabilities HOT 2
- router-lite: null/undefined in optional parameters HOT 5
- package "exports" field prevents importing dev builds without a bundler HOT 3
- AUR3352: Unexpected state at swap of VPA
- Aurelia Router - Duplicate content
- Portal attribute: aurelia markup <!--au-start--><!--au-end--> are not removed
- Calling store.dispatch in sequence will only set the new state once
- Incorrect injection of parent custom element HOT 6
- New instance injected when using CustomElementDefinition#dependencies HOT 1
- OPEN COLLECTIVE FUNDS HOT 2
- [feature request] state plugin should be able to connect to redux devtools HOT 1
- 🏁 Roadmap & Iteration plan Q1 2024 HOT 3
- flickering caused by aurelia rendering content before clearing the old HOT 2
- [RFC] Custom element bindables take priority over custom attribute
- [refactor] remove define life cycle HOT 1
- Vite plugin for aurelia 1.x? HOT 4
- Router load attribute: broken when using id & parameters.bind HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aurelia.