Browse Source

rename `props` options to `proto`

Evan You 12 years ago
parent
commit
9405ed720f
5 changed files with 13 additions and 15 deletions
  1. 0 2
      TODO.md
  2. 1 1
      examples/nested-props.html
  3. 1 1
      examples/todomvc/js/app.js
  4. 6 6
      src/main.js
  5. 5 5
      test/unit/specs/api.js

+ 0 - 2
TODO.md

@@ -1,10 +1,8 @@
-- `pop`, `remove` and `shift` should return undefined and not throw error
 - put all API methods on Seed
 - add a method to observe additional data properties
 - add `lazy` option
 - add directive for all form elements, and make it consistent as `sd-model`
 - add escape: {{{ things in here should not be parsed }}}
-- rename `props` option to `proto`
 - properties that start with `_` should also be ignored and used as a convention: `$` is library properties, `_` is user properties and non-prefixed properties are data.
 
 - sd-transition

+ 1 - 1
examples/nested-props.html

@@ -26,7 +26,7 @@
                     this.msg = 'Yoyoyo'
                     this.a = data
                 },
-                props: {
+                proto: {
                     one: function () {
                         this.a = {
                             c: 1,

+ 1 - 1
examples/todomvc/js/app.js

@@ -12,7 +12,7 @@ var Todos = seed.ViewModel.extend({
         this.updateFilter()
     },
 
-    props: {
+    proto: {
 
         updateFilter: function () {
             var filter = location.hash.slice(2)

+ 6 - 6
src/main.js

@@ -75,11 +75,11 @@ function extend (options) {
     var proto = ExtendedVM.prototype = Object.create(ParentVM.prototype)
     utils.defProtected(proto, 'constructor', ExtendedVM)
     // copy prototype props
-    var props = options.props
-    if (props) {
-        for (var key in props) {
+    var protoMixins = options.proto
+    if (protoMixins) {
+        for (var key in protoMixins) {
             if (!(key in ViewModel.prototype)) {
-                proto[key] = props[key]
+                proto[key] = protoMixins[key]
             }
         }
     }
@@ -101,7 +101,7 @@ function extend (options) {
  *  they should be further extended. However extending should only
  *  be done at top level.
  *  
- *  `props` is an exception because it's handled directly on the
+ *  `proto` is an exception because it's handled directly on the
  *  prototype.
  *
  *  `el` is an exception because it's not allowed as an
@@ -112,7 +112,7 @@ function inheritOptions (child, parent, topLevel) {
     convertPartials(child.partials)
     if (!parent) return child
     for (var key in parent) {
-        if (key === 'el' || key === 'props') continue
+        if (key === 'el' || key === 'proto') continue
         if (!child[key]) { // child has priority
             child[key] = parent[key]
         } else if (topLevel && utils.typeOf(child[key]) === 'Object') {

+ 5 - 5
test/unit/specs/api.js

@@ -264,17 +264,17 @@ describe('UNIT: API', function () {
 
             })
 
-            describe('props', function () {
+            describe('proto', function () {
                 
                 it('should be mixed to the exteded VM\'s prototype', function () {
-                    var props = {
+                    var mixins = {
                         a: 1,
                         b: 2,
                         c: function () {}
                     }
-                    var Test = seed.ViewModel.extend({ props: props })
-                    for (var key in props) {
-                        assert.strictEqual(Test.prototype[key], props[key])
+                    var Test = seed.ViewModel.extend({ proto: mixins })
+                    for (var key in mixins) {
+                        assert.strictEqual(Test.prototype[key], mixins[key])
                     }
                 })