Skip to content

Conversation

sfthurber
Copy link

bug:
var ractive = Ractive({
fix:
var ractive = new Ractive({

bug:
var ractive = Ractive({
fix:
var ractive = new Ractive({
@sfthurber sfthurber changed the title change line 33 to: var ractive = new Ractive({ fix bug in tutorial step1 code line 33 -- as corrected: var ractive = new Ractive({ Jun 1, 2018
@sfthurber sfthurber changed the title fix bug in tutorial step1 code line 33 -- as corrected: var ractive = new Ractive({ fix bug in https://ractive.js.org/tutorials/hello-world/ step 1, code line 33 Jun 1, 2018
@fskreuz
Copy link
Collaborator

fskreuz commented Jun 1, 2018

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

@sfthurber
Copy link
Author

sfthurber commented Jun 1, 2018 via email

@sfthurber
Copy link
Author

sfthurber commented Jun 1, 2018 via email

@fskreuz
Copy link
Collaborator

fskreuz commented Jun 1, 2018

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.

@sfthurber
Copy link
Author

sfthurber commented Jun 1, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants