These are chat archives for canjs/canjs

28th
Apr 2017
Gira Minus
@gKreator
Apr 28 2017 00:05
you mean like when im passing from child to parent, i dont have to predefine the property on the parent?
Brad Momberger
@bmomberger-bitovi
Apr 28 2017 00:06
That's a different matter. You should pre-define the property on the parent, not just for posterity, but because with sealed DefineMaps, the value won't be accepted without a definition.
I'm spitballing ways to avoid issues child-to-parent binding in staches caused by intervening scope stack additions
Gira Minus
@gKreator
Apr 28 2017 00:09
i couldnt think of anything better than what exists currently since i have not even tried to read all of the canjs + donejs source code
Gregg Roemhildt
@roemhildtg
Apr 28 2017 13:40
Question on DefineMaps. If I have a get on a property, does that also mean I need to have a set on the property in order to try and set that value?
I just started seeing lots of failed tests with the error setting a property that has only a getter
My tests are using firefox 51 on travis
Kevin Phillips
@phillipskevin
Apr 28 2017 14:02
you don’t need to have a set
are you sure that error is related to your own DefineMaps?
there was a bug in can-util@3.4.0 that was causing this error
Gregg Roemhildt
@roemhildtg
Apr 28 2017 14:04
Let me take a look at which version that is with
It looks like its with can-util@3.5.x
Kevin Phillips
@phillipskevin
Apr 28 2017 14:10
ok
would you mind opening an issue?
in can-define
Gregg Roemhildt
@roemhildtg
Apr 28 2017 14:11
Sure thing.
Kevin Phillips
@phillipskevin
Apr 28 2017 14:13
and you’re sure it’s not pulling in an older can-util
npm ls can-util should show you
Jeroen Cornelissen
@jeroencornelissen
Apr 28 2017 14:13
@roemhildtg @phillipskevin I just updated to can-define 1.0.18, and I also get this error
Kevin Phillips
@phillipskevin
Apr 28 2017 14:14
ok, same question about can-util
Gregg Roemhildt
@roemhildtg
Apr 28 2017 14:14
image.png
Its on travis, so I can't do npm ls but it says its version 3.5.1
Kevin Phillips
@phillipskevin
Apr 28 2017 14:15
ok
Gregg Roemhildt
@roemhildtg
Apr 28 2017 14:15
is canjs/can-define#180 related?
Kevin Phillips
@phillipskevin
Apr 28 2017 14:16
that’s what I just checked
those tests were failing with can-util@3.4.0
but they’re working again now
Jeroen Cornelissen
@jeroencornelissen
Apr 28 2017 14:17
└─┬ can-component@3.0.7
└── can-util@3.3.2
even with └─ can-util@3.5.1 I get the error
Kevin Phillips
@phillipskevin
Apr 28 2017 14:20
ok
thank you both for confirming
I’m trying to reproduce the error now
a simple example like this doesn’t have the issue
const M = DefineMap.extend({
  prop: {
    value: 'Hi',
    get(val) {
      return val + '!';
    }
  }
});
Gregg Roemhildt
@roemhildtg
Apr 28 2017 14:27
What if you do something more complex like
    fields: {
        Type: DefineMap.extend({ prop : 'string' }),
        Value: DefineMap.extend({ prop : 'string' }),
        get (fields) {
              return {
                 prop: fields.prop + 'something'
              }
        }
    },
Jeroen Cornelissen
@jeroencornelissen
Apr 28 2017 14:28
Adding a set here, solved this error:
hasDefaultList : {
    type: 'boolean',
    value: false,
    set : function(newValue) {
        return newValue;
    }
},
The property didn’t had a set or a get
Kevin Phillips
@phillipskevin
Apr 28 2017 14:30
neither of those examples cause a problem for me
I’m going to explicitly upgrade the can-util version in can-define and release a patch
to see if that fixes the issue for you
Jeroen Cornelissen
@jeroencornelissen
Apr 28 2017 14:34
reinstalled can-define@1.0.17 but now i get an error on can-control
Cannot read property 'splice' of undefined
Kevin Phillips
@phillipskevin
Apr 28 2017 14:36
ok, if you can open an issue for that also that would help
we’re trying to get canjs 3.6.0 out today, so we’ll be running our integration tests
Matthew Phillips
@matthewp
Apr 28 2017 14:37
can you debug what is trying to set it?
Jeroen Cornelissen
@jeroencornelissen
Apr 28 2017 14:40
Schermafbeelding 2017-04-28 om 16.39.56.png
Kevin Phillips
@phillipskevin
Apr 28 2017 14:44
can-define@1.0.19 is out with an updated can-util version
you can try that to see if it resolves the setting a property that has only a getter error
Stef
@sronsiek
Apr 28 2017 14:48
Hi - I have a frustrated canjs newbie qu - hope this is allowed here!
Jeroen Cornelissen
@jeroencornelissen
Apr 28 2017 14:49
@phillipskevin no it didn't
Cannot set property items of #<Object> which has only a getter
Justin Meyer
@justinbmeyer
Apr 28 2017 14:50
@sronsiek allowed! :-)
(though you have 10 min before a bunch of the core team has standup)
Stef
@sronsiek
Apr 28 2017 14:52
Thx! ($click)="sampleViewModelFunc()" in my stache template does what it's supposed to, but return '($click)="sampleViewModelFunc()"' from a helper does not. It looks the same in the dom but nothing triggers, canjs2.
maybe an escaping issue?
Justin Meyer
@justinbmeyer
Apr 28 2017 14:54
you have a helper that returns '($click)="sampleViewModelFunc()"' ?
a helper used like <foo {{helper}}/>` ?
Stef
@sronsiek
Apr 28 2017 14:54
it's called from stache like this:
{{{getAction2 item}}}
Justin Meyer
@justinbmeyer
Apr 28 2017 14:55
dynamic event bindings won't work from helpers like that .... however, you can create a helper that listens to click on your own (or a custom attr which would probably be better).
registerHelper("getAction", function(action, opts){

  return function(el) {
    $(el).click(function(){
     var actionValue = action();
     // depending on actionValue, maybe look up the function
     var sampleViewModelFunc = opts.scope.get("@"+actionValue)
     sampleViewModelFunc();
    })
  }
})
something like that
helpers that return functions get called w/ the element
Gregg Roemhildt
@roemhildtg
Apr 28 2017 14:58
@phillipskevin sorry, the build is still failing, but I can't spend too much time on this at the moment. Gotta look into some other app issues atm. I'll report back this weekend on debugging
Stef
@sronsiek
Apr 28 2017 14:58
maybe some context: item contains an 'action' which can be a js function, a string to a viewModel func, or a url
Justin Meyer
@justinbmeyer
Apr 28 2017 14:59
yeah, then you can decide what to do w/ what action's value is
Stef
@sronsiek
Apr 28 2017 14:59
the helper is supposed to return the right thing ... $(click) work well with a viewModel func
Justin Meyer
@justinbmeyer
Apr 28 2017 14:59
I don't know what you mean
"return the right thing"
is there something about the code I shared that isn't clear?
Stef
@sronsiek
Apr 28 2017 14:59
for url I just need href={{action}}" etc
Justin Meyer
@justinbmeyer
Apr 28 2017 15:00
it should be able to get you started solving practically any pattern you need from a helper like <div {{helper arg}}>
Stef
@sronsiek
Apr 28 2017 15:00
I'll try it offline - I needed pointing to the right approach
Justin Meyer
@justinbmeyer
Apr 28 2017 15:01
opts.scope.get reads a value from the scope (might be opts.scope.attr in CanJS 2.3)
Stef
@sronsiek
Apr 28 2017 15:02
Great - thx - will give it a shot
Gregg Roemhildt
@roemhildtg
Apr 28 2017 15:37
@phillipskevin this is throwing the error for me:
<script src="./node_modules/steal/steal.js" main="@loader">
import DefineMap from 'can-define/map/map';

export const Filter = DefineMap.extend('Filter', {
    value: {
        type: '*'
    },
    name: {
        type: 'string',
        get (name) {
            return name || 'test';
        },
        serialize (name) {
            return name;
        }
    },
    operator: {
        type: 'string',
        value: 'like'
    }
});

console.log(new Filter({
      name: 'test',
      operator: 'equals',
      value: 'test'
}));
</script>
image.png
Kevin Phillips
@phillipskevin
Apr 28 2017 15:38
thanks
would you mind adding it to the issue?
canjs/can-define#182
Stef
@sronsiek
Apr 28 2017 15:40
opts.scope.get("@"+actionValue) ... the function lookup does not work. action contains "sampleViewModelFunc()" as expected. canjs 2.3.24 - also tried opts.attr("@"+actionValue) This was another thing I was trying to solve: how to get handles on viewModel fincs from the helper. Inspection of opts scope in the browser does not reveal presence of the sampleViewModelFunc ;(
Christopher Baker
@christopherjbaker
Apr 28 2017 15:44
@roemhildtg @phillipskevin in that snippet, its actually the operator set that is erroring for me, value and name work fine without operator: 'equals'
Gregg Roemhildt
@roemhildtg
Apr 28 2017 15:45
Correct
So apparently it isn't the getter that's causing the issue
Brad Momberger
@bmomberger-bitovi
Apr 28 2017 18:50
So as to restore everyone's confidence, we have tracked down the issue and have a fix; we are currently dev-reviewing and QA'ing it.
Jeroen Cornelissen
@jeroencornelissen
Apr 28 2017 19:00
:clap:
Gira Minus
@gKreator
Apr 28 2017 19:04
:factory:
Brad Momberger
@bmomberger-bitovi
Apr 28 2017 19:17
Good news everyone!
can-define 1.0.20 fixes the "property only has a getter" issue.
get at your npms.
Gira Minus
@gKreator
Apr 28 2017 19:44
:D
I think i saw that error the other day
What was it triggered by?
Kevin Phillips
@phillipskevin
Apr 28 2017 19:45
This case was a very subtle change with how DefineMaps are initialized
if you have a property with a prop: { value: ‘foo’ } and you pass a default when the DefineMap is constructed like new MyMap({ prop: ‘bar’ });
there was another bug the other day that caused the same error in a wider set of cases
that one was fixed pretty quickly
Mohamed Cherif Bouchelaghem
@cherifGsoul
Apr 28 2017 21:10
@bmomberger-bitovi thank you