These are chat archives for canjs/canjs

4th
Aug 2017
Viktor Busko
@Lighttree
Aug 04 2017 08:50

Guys, in mustache it was possible to create such helper:
{{l10n 'something' 0=value 1=value2}}

And helper's hash has was:

{0: value, 1: value2}

But when I try to do this way in stache helperOptions looks like:

0:"something"
1:0
2:value
3:1

no hash or something else.
Is it unsafe and prohibited to use just numbers as keys (if I wrap it as strings the issue still there, it will be like 1:'0') ? Or this is a bug ?
Because if I do something like:
{{l10n 'something' prop_1=value prop_2=value2}}
Everything works as expected.

tried:
Call Expression
Hash Expression
Helper Expression

Kevin Phillips
@phillipskevin
Aug 04 2017 14:17
@Lighttree submit an issue, we'll look into it
Gregg Roemhildt
@roemhildtg
Aug 04 2017 16:09
Define maps that have an array property with values, when that value is set to an empty array it doesn't change. Is this expected behavior ?
http://jsbin.com/monivureza/edit?html,js,console,output
Brad Momberger
@bmomberger-bitovi
Aug 04 2017 16:09
@lighttree's issue is a Known issue: canjs/can-stache#203
Now if someone on the OS team would be nice enough to fix it. :)
Kevin Phillips
@phillipskevin
Aug 04 2017 18:29
I added it to an upcoming version @bmomberger-bitovi @Lighttree
so we'll try to address it
@roemhildtg what do you mean it doesn't change?
Gregg Roemhildt
@roemhildtg
Aug 04 2017 18:32
Using the map.set({ prop: ['new'] }) doesn't update the prop value
Kevin Phillips
@phillipskevin
Aug 04 2017 18:32
ok, that's not shown in your jsbin, right?
Gregg Roemhildt
@roemhildtg
Aug 04 2017 18:33
The first console print line does show it
It should print 0
but it prints 3
Kevin Phillips
@phillipskevin
Aug 04 2017 18:33
oh, duh
sorry, I missed the set completely
Gregg Roemhildt
@roemhildtg
Aug 04 2017 18:33
:wink:
tis friday.
I put an issue up canjs/can-define#243
Kevin Phillips
@phillipskevin
Aug 04 2017 18:36
thanks :thumbsup: we'll take a look
if you use
.set({
  list: []
}, true)
it works
Gregg Roemhildt
@roemhildtg
Aug 04 2017 18:39
It does, but I don't really want it to remove the other properties, which I think that does
Michael Price
@web-mech
Aug 04 2017 18:39
isn’t that what you’re trying to do anyways?
Gregg Roemhildt
@roemhildtg
Aug 04 2017 18:40
I'm just trying to replace properties that get changed in a form. I have a dirty object with values that get set as the form fields change, and I want to update my model object with the changed values. Some values won't change, and won't be in the dirty, so setting true would remove those values from the model object
Kevin Phillips
@phillipskevin
Aug 04 2017 18:41
ok
Michael Price
@web-mech
Aug 04 2017 18:41
gotcha
Kevin Phillips
@phillipskevin
Aug 04 2017 18:41
and you want to be able to call set with an object so you can set multiple properties
instead of using splice or something on the list itsself
Gregg Roemhildt
@roemhildtg
Aug 04 2017 18:42
Yes, that's right
Kevin Phillips
@phillipskevin
Aug 04 2017 18:42
ok
Gregg Roemhildt
@roemhildtg
Aug 04 2017 18:44
the form object's properties can be strings, ints, etc, in one case I have it set to a list so I can have a list of items, like checkboxes
But that list is one field
so if that field changes, it gets added to the dirty object to be validated, then submitted
for now, I can just iterate the fields, and update the props one by one. But set would be nicer
I think that map.set({ prop: [] }); and map.prop = [] should do the same thing, right?
Kevin Phillips
@phillipskevin
Aug 04 2017 18:49
in this case, they probably should do the same thing
but it obviously has to go through different code paths
in case you have something like map.set({ foo: { bar: { baz: [] } } })
Gregg Roemhildt
@roemhildtg
Aug 04 2017 18:50
right, that makes sense
I can see the benefit to deep assigning objects, thats clear but when would you want to deep assign array?