Giter Site home page Giter Site logo

Comments (10)

EisenbergEffect avatar EisenbergEffect commented on May 14, 2024

The looser comparison seems like it might be the way to go, rather than coercing values.

from aurelia.

fkleuver avatar fkleuver commented on May 14, 2024

Can you elaborate?

You mean a == b instead of (a+'') === b or?

from aurelia.

EisenbergEffect avatar EisenbergEffect commented on May 14, 2024

I meant this value === true || value === 'true'. Or is this two separate issues?

from aurelia.

fkleuver avatar fkleuver commented on May 14, 2024

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.

EisenbergEffect avatar EisenbergEffect commented on May 14, 2024

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.

fkleuver avatar fkleuver commented on May 14, 2024

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.

bigopon avatar bigopon commented on May 14, 2024

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.

fkleuver avatar fkleuver commented on May 14, 2024

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.

davismj avatar davismj commented on May 14, 2024

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.

bigopon avatar bigopon commented on May 14, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.