These are chat archives for canjs/canjs

1st
Sep 2015
Nikolay Nadorichev
@Luanre
Sep 01 2015 11:23
Is it possible to render component's template only if no content passed to can.Component ?
Chris Gomez
@akagomez
Sep 01 2015 13:01
@Luanre That’s a good question. As far as I know, no.
Mohamed Cherif Bouchelaghem
@cherifGsoul
Sep 01 2015 13:12
@Luanre I was wondering that too for example page component should only change the content
Matthew Phillips
@matthewp
Sep 01 2015 14:39
You could implement this yourself in inserted
something like
this.attr("emptyContents", this.element.children().length === 0)
this wouldn't be dynamic, of course
would need mutation observers for that
Nikolay Nadorichev
@Luanre
Sep 01 2015 14:42
I've tried it
Mohamed Cherif Bouchelaghem
@cherifGsoul
Sep 01 2015 14:42
@matthewp a use case for this hybrid mobile apps
Nikolay Nadorichev
@Luanre
Sep 01 2015 14:42
in inserted event component already have rendered template
Matthew Phillips
@matthewp
Sep 01 2015 14:43
it should be empty though, right?
unless you have stuff in your own template
you want to wrap your own template like
{{#if emptyContents}} ... {{/if}}
Nikolay Nadorichev
@Luanre
Sep 01 2015 14:50
Ah, yeah, works like a charm, thank you!
my mistake was: {{#if emptyContents}}...{{else}}<content />{{/if}}
Paul Tichonczuk
@tracer99
Sep 01 2015 19:35
If a key in a map is "watch", FF throws an error: 'TypeError: missing argument 1 when calling function this[prop]' because watch is a function in can.Map
should I file this as a bug or is there something I'm missing?
Matthew Phillips
@matthewp
Sep 01 2015 19:39
there's a function named watch on can.Map?
is that your function?
Paul Tichonczuk
@tracer99
Sep 01 2015 19:39
no
sec. I'll get you the details
Matthew Phillips
@matthewp
Sep 01 2015 19:40
map = new can.Map
map.watch // -> undefined
Paul Tichonczuk
@tracer99
Sep 01 2015 19:43
when I do this in FF I get function
I assumed it was a CanJS thing, but I can't actual find where this function is defined
Paul Tichonczuk
@tracer99
Sep 01 2015 19:51
of course I wouldn't be accessing map.watch but running map.attr("watch"); which is when the error is thrown
Matthew Phillips
@matthewp
Sep 01 2015 19:53
what happens if you try map.attr("toString") ? same behavior?
Paul Tichonczuk
@tracer99
Sep 01 2015 19:56
hah
it returns the toString function reference
it does not throw an error
m.attr("toString", "something"); throws TypeError: [].slice is not a function
Chris Gomez
@akagomez
Sep 01 2015 19:57
Can you print the fn with map.watch?
console.log(map.watch)
Paul Tichonczuk
@tracer99
Sep 01 2015 19:58
"function watch()"
if you use get and set directly, it works fine
only when using attr does it not work correctly (or accessing the property directly like above)
Matthew Phillips
@matthewp
Sep 01 2015 20:00
I would file an issue, might be able to do something about it
I bet we are not using hasOwnProperty
Paul Tichonczuk
@tracer99
Sep 01 2015 20:01
I might just fix it and submit a patch