Skip to content

fix bug in https://ractive.js.org/tutorials/hello-world/ step 1, code line 33 #154

Open
sfthurber wants to merge 1 commit into
ractivejs:devfrom
sfthurber:patch-1
Open

fix bug in https://ractive.js.org/tutorials/hello-world/ step 1, code line 33 #154
sfthurber wants to merge 1 commit into
ractivejs:devfrom
sfthurber:patch-1

Conversation

@sfthurber

Copy link
Copy Markdown

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
@ghost

ghost commented Jun 1, 2018

Copy link
Copy Markdown

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

sfthurber commented Jun 1, 2018 via email

Copy link
Copy Markdown
Author

@sfthurber

sfthurber commented Jun 1, 2018 via email

Copy link
Copy Markdown
Author

@ghost

ghost commented Jun 1, 2018

Copy link
Copy Markdown

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

sfthurber commented Jun 1, 2018 via email

Copy link
Copy Markdown
Author

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.

1 participant