Open sfthurber opened 6 years ago
Hi! Thanks for the PR (your very first one to be precise 🎉 ). Unfortunately, it's not a bug. Ractive
can be called with or without new
. Under the hood, Ractive has a "constructor guard" which creates a new instance with new
if the constructor was invoked as a regular function.
See https://github.com/ractivejs/ractive/blob/dev/src/Ractive.js#L35
well, it didn't work in the tutorial when i pasted the code in.it worked after l i clicked "fix code" which changed the instantiation to an explicit "new". so i viewed that as a bug in the tutorial.
On 6/1/18, Joseph notifications@github.com wrote:
Hi! Thanks for the PR (your very first one to be precise 🎉 ). Unfortunately, it's not a bug. Ractive instances can be instantiated with or without
new
. Under the hood, Ractive has a "constructor guard" which creates a new instance withnew
if the constructor was like a regular function.See https://github.com/ractivejs/ractive/blob/dev/src/Ractive.js#L34
-- You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub: https://github.com/ractivejs/ractivejs.github.io/pull/154#issuecomment-393875762
i'll re-try it and send so screen captures
On 6/1/18, Steve sfthurber@gmail.com wrote:
well, it didn't work in the tutorial when i pasted the code in.it worked after l i clicked "fix code" which changed the instantiation to an explicit "new". so i viewed that as a bug in the tutorial.
On 6/1/18, Joseph notifications@github.com wrote:
Hi! Thanks for the PR (your very first one to be precise 🎉 ). Unfortunately, it's not a bug. Ractive instances can be instantiated with or without
new
. Under the hood, Ractive has a "constructor guard" which creates a new instance withnew
if the constructor was like a regular function.See https://github.com/ractivejs/ractive/blob/dev/src/Ractive.js#L34
-- You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub: https://github.com/ractivejs/ractivejs.github.io/pull/154#issuecomment-393875762
Ahh... It might be because the copy-paste code looks like
var ractive = Ractive({
target: output,
template: template,
data: { greeting: 'Hello', name: 'world' }
});
but the Fix Code code looks like:
var ractive = new Ractive({
target: '#target',
template: '#template',
data: { greeting: 'Hello', name: 'world' }
});
Notice the target
and template
. If this is the case, this would be the bug in the docs.
this may help--screen captures attached
On 6/1/18, Joseph notifications@github.com wrote:
Ahh... It might be because the copy-paste code looks like
var ractive = Ractive({ target: output, template: template, data: { greeting: 'Hello', name: 'world' } });
but the Fix Code code looks like:
var ractive = new Ractive({ target: '#target', template: '#template', data: { greeting: 'Hello', name: 'world' } });
Notice the
target
andtemplate
. If this is the case, this would be the bug.-- You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub: https://github.com/ractivejs/ractivejs.github.io/pull/154#issuecomment-393882420
bug: var ractive = Ractive({ fix: var ractive = new Ractive({