mirror of
https://github.com/pebble-dev/clay.git
synced 2026-09-05 16:47:37 -04:00
Stop exposing config as a reference. resolves #35
This commit is contained in:
@@ -613,7 +613,7 @@ Pebble.addEventListener('webviewclosed', function(e) {
|
|||||||
|
|
||||||
| Property | Type | Description |
|
| Property | Type | Description |
|
||||||
|----------|------|-------------|
|
|----------|------|-------------|
|
||||||
| `.config` | Array | Reference to the config passed to the constructor and used for generating the page. **WARNING** this is a direct reference, not a copy of the config so any modification you make to it, will be reflected on the original as well |
|
| `.config` | Array | Copy of the config passed to the constructor and used for generating the page. |
|
||||||
| `.customFn` | Function | Reference to the custom function passed to the constructor. **WARNING** this is a direct reference, not a copy of the custom function so any modification you make to it, will be reflected on the original as well |
|
| `.customFn` | Function | Reference to the custom function passed to the constructor. **WARNING** this is a direct reference, not a copy of the custom function so any modification you make to it, will be reflected on the original as well |
|
||||||
| `.meta` | Object | Contains information about the current user and watch. **WARNING** This will only be populated in the `showConfiguration` event handler. (See example above) |
|
| `.meta` | Object | Contains information about the current user and watch. **WARNING** This will only be populated in the `showConfiguration` event handler. (See example above) |
|
||||||
| `.meta.activeWatchInfo` | watchinfo\|null | An object containing information on the currently connected Pebble smartwatch or null if unavailable. Read more [here](https://developer.pebble.com/docs/js/Pebble/#getActiveWatchInfo). |
|
| `.meta.activeWatchInfo` | watchinfo\|null | An object containing information on the currently connected Pebble smartwatch or null if unavailable. Read more [here](https://developer.pebble.com/docs/js/Pebble/#getActiveWatchInfo). |
|
||||||
|
|||||||
+3
-1
@@ -94,7 +94,9 @@ gulp.task('clay', ['inlineHtml'], function() {
|
|||||||
.bundle()
|
.bundle()
|
||||||
.pipe(source('clay.js'))
|
.pipe(source('clay.js'))
|
||||||
.pipe(buffer())
|
.pipe(buffer())
|
||||||
.pipe(uglify())
|
.pipe(uglify({
|
||||||
|
preserveComments: 'license'
|
||||||
|
}))
|
||||||
.pipe(insert.prepend(versionMessage))
|
.pipe(insert.prepend(versionMessage))
|
||||||
.pipe(gulp.dest('./dist/'));
|
.pipe(gulp.dest('./dist/'));
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ var configPageHtml = require('./tmp/config-page.html');
|
|||||||
var toSource = require('tosource');
|
var toSource = require('tosource');
|
||||||
var standardComponents = require('./src/scripts/components');
|
var standardComponents = require('./src/scripts/components');
|
||||||
var utils = require('./src/scripts/lib/utils');
|
var utils = require('./src/scripts/lib/utils');
|
||||||
|
var deepcopy = require('deepcopy/build/deepcopy.min');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Array} config - the Clay config
|
* @param {Array} config - the Clay config
|
||||||
@@ -27,7 +28,7 @@ function Clay(config, customFn, options) {
|
|||||||
|
|
||||||
options = options || {};
|
options = options || {};
|
||||||
|
|
||||||
self.config = config;
|
self.config = deepcopy(config);
|
||||||
self.customFn = customFn || function() {};
|
self.customFn = customFn || function() {};
|
||||||
self.components = {};
|
self.components = {};
|
||||||
self.meta = {
|
self.meta = {
|
||||||
|
|||||||
@@ -35,6 +35,7 @@
|
|||||||
"browserify-istanbul": "^0.2.1",
|
"browserify-istanbul": "^0.2.1",
|
||||||
"chai": "^3.4.1",
|
"chai": "^3.4.1",
|
||||||
"deamdify": "^0.2.0",
|
"deamdify": "^0.2.0",
|
||||||
|
"deepcopy": "^0.6.1",
|
||||||
"del": "^2.0.2",
|
"del": "^2.0.2",
|
||||||
"eslint": "^1.5.1",
|
"eslint": "^1.5.1",
|
||||||
"eslint-config-pebble": "^1.2.0",
|
"eslint-config-pebble": "^1.2.0",
|
||||||
|
|||||||
@@ -135,6 +135,15 @@ describe('Clay', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('.config', function() {
|
||||||
|
it('is a copy not a reference', function() {
|
||||||
|
var config = fixture.config(['input', 'text', 'color']);
|
||||||
|
var clay = fixture.clay(config);
|
||||||
|
assert.notStrictEqual(clay.config, config);
|
||||||
|
assert.deepEqual(clay.config, config);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('.registerComponent()', function() {
|
describe('.registerComponent()', function() {
|
||||||
it('adds the component to the this.components', function() {
|
it('adds the component to the this.components', function() {
|
||||||
var clay = fixture.clay([]);
|
var clay = fixture.clay([]);
|
||||||
|
|||||||
Reference in New Issue
Block a user