Skip to content

Commit

Permalink
Be consistent with spacing [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
dead-claudia committed Nov 22, 2018
1 parent bc63322 commit e164c6e
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions docs/components.md
Expand Up @@ -126,7 +126,7 @@ function ComponentWithState(initialVnode) {
// Component state variable, unique to each instance
var count = 0

// POJO component instance: any object with a
// POJO component instance: any object with a
// view function which returns a vnode
return {
oninit: function(vnode){
Expand Down Expand Up @@ -535,14 +535,14 @@ var Stats = {
}

var MyModal = {
view: function () {
view: function() {
return m(Modal, {
// This hook is called for both the component and the modal element
// itself, causing two event listeners to be registered onto the
// DOM element. This means your stat counter is now twice what it
// should be.
oncreate: function (vnode) {
$(vnode.dom).on("show.bs.modal", function () {
oncreate: function(vnode) {
$(vnode.dom).on("show.bs.modal", function() {
Stats.send("modal open", "MyModal")
})
}
Expand Down Expand Up @@ -648,13 +648,13 @@ var Stats = {
}

var MyModal = {
view: function () {
view: function() {
return m(Modal, {
modalAttrs: {
// This hook is called only once and thus only one event
// listener attached, so your stat counter works.
oncreate: function (vnode) {
$(vnode.dom).on("show.bs.modal", function () {
oncreate: function(vnode) {
$(vnode.dom).on("show.bs.modal", function() {
Stats.send("modal open", "MyModal")
})
}
Expand All @@ -676,12 +676,12 @@ Of course, the `MyModal` example is better written as this:
```js
// This uses the preferred `Modal` version.
var BetterMyModal = {
view: function () {
view: function() {
return m(Modal, {
modalAttrs: {
// Only one event listener is attached here, so your stat
// counter works.
"onshow.bs.modal": function () {
"onshow.bs.modal": function() {
Stats.send("modal open", "MyModal")
}
},
Expand All @@ -697,7 +697,7 @@ But, this only works with DOM events. Also, you won't notice bugs initially when
// This is broken if you're using the original `Modal`, but it certainly doesn't
// look like it's broken!
m(Modal, {
onupdate: function (vnode) {
onupdate: function(vnode) {
$(vnode.dom).modal("toggle")
}
}, [
Expand Down

0 comments on commit e164c6e

Please sign in to comment.