mirror of
https://github.com/pebble-dev/clay.git
synced 2026-09-05 08:37:43 -04:00
pass minified to initialize function
This commit is contained in:
+3
-2
@@ -8,7 +8,7 @@
|
|||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test-travis": "./node_modules/.bin/karma start ./test/karma.conf.js --single-run --browsers chromeTravisCI && ./node_modules/.bin/eslint ./",
|
"test-travis": "./node_modules/.bin/karma start ./test/karma.conf.js --single-run --browsers chromeTravisCI && ./node_modules/.bin/eslint ./",
|
||||||
"test-debug": "DEBUG=true && ./node_modules/.bin/karma start ./test/karma.conf.js --no-single-run",
|
"test-debug": "(export DEBUG=true && ./node_modules/.bin/karma start ./test/karma.conf.js --no-single-run)",
|
||||||
"test": "./node_modules/.bin/karma start ./test/karma.conf.js --single-run",
|
"test": "./node_modules/.bin/karma start ./test/karma.conf.js --single-run",
|
||||||
"lint": "./node_modules/.bin/eslint ./",
|
"lint": "./node_modules/.bin/eslint ./",
|
||||||
"build": "gulp"
|
"build": "gulp"
|
||||||
@@ -28,7 +28,6 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/pebble/clay#readme",
|
"homepage": "https://github.com/pebble/clay#readme",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"pebble-clay-components": "git+https://github.com/pebble/clay-components.git#master",
|
|
||||||
"browserify": "^13.0.0",
|
"browserify": "^13.0.0",
|
||||||
"browserify-istanbul": "^0.2.1",
|
"browserify-istanbul": "^0.2.1",
|
||||||
"chai": "^3.4.1",
|
"chai": "^3.4.1",
|
||||||
@@ -52,6 +51,8 @@
|
|||||||
"karma-source-map-support": "^1.1.0",
|
"karma-source-map-support": "^1.1.0",
|
||||||
"karma-threshold-reporter": "^0.1.15",
|
"karma-threshold-reporter": "^0.1.15",
|
||||||
"mocha": "^2.3.4",
|
"mocha": "^2.3.4",
|
||||||
|
"pebble-clay-components": "git+https://github.com/pebble/clay-components.git#master",
|
||||||
|
"sassify": "^0.9.1",
|
||||||
"sinon": "^1.17.3",
|
"sinon": "^1.17.3",
|
||||||
"stringify": "^3.2.0",
|
"stringify": "^3.2.0",
|
||||||
"vinyl-source-stream": "^1.1.0",
|
"vinyl-source-stream": "^1.1.0",
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var componentRegistry = require('./component-registry');
|
var componentRegistry = require('./component-registry');
|
||||||
var _ = require('../vendor/minified/minified')._;
|
var minified = require('../vendor/minified/minified');
|
||||||
var HTML = require('../vendor/minified/minified').HTML;
|
|
||||||
var utils = require('../lib/utils');
|
var utils = require('../lib/utils');
|
||||||
var ClayEvents = require('./clay-events');
|
var ClayEvents = require('./clay-events');
|
||||||
|
|
||||||
|
var _ = minified._;
|
||||||
|
var HTML = minified.HTML;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @extends ClayEvents
|
* @extends ClayEvents
|
||||||
* @param {Clay~ConfigItem} config
|
* @param {Clay~ConfigItem} config
|
||||||
@@ -33,7 +35,7 @@ function ClayItem(config) {
|
|||||||
self.config = config;
|
self.config = config;
|
||||||
|
|
||||||
/** @type {M} */
|
/** @type {M} */
|
||||||
self.$element = HTML(_.formatHtml(_component.template, _templateData));
|
self.$element = HTML(_component.template.trim(), _templateData);
|
||||||
|
|
||||||
/** @type {M} */
|
/** @type {M} */
|
||||||
self.$manipulatorTarget = self.$element.select('[data-manipulator-target]');
|
self.$manipulatorTarget = self.$element.select('[data-manipulator-target]');
|
||||||
@@ -44,12 +46,13 @@ function ClayItem(config) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run the initializer if it exists.
|
* Run the initializer if it exists and attaches the css to the head.
|
||||||
|
* Passes minified as the first param
|
||||||
* @returns {ClayItem}
|
* @returns {ClayItem}
|
||||||
*/
|
*/
|
||||||
self.initialize = function() {
|
self.initialize = function() {
|
||||||
if (typeof _component.initialize === 'function') {
|
if (typeof _component.initialize === 'function') {
|
||||||
_component.initialize.apply(self, arguments);
|
_component.initialize.call(self, minified);
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ var assert = require('chai').assert;
|
|||||||
var sinon = require('sinon');
|
var sinon = require('sinon');
|
||||||
var checkReadOnly = require('../../test-utils').checkReadOnly;
|
var checkReadOnly = require('../../test-utils').checkReadOnly;
|
||||||
var ClayItem = require('../../../src/scripts/lib/clay-item');
|
var ClayItem = require('../../../src/scripts/lib/clay-item');
|
||||||
|
var minified = require('../../../src/scripts/vendor/minified/minified');
|
||||||
var clayItemFixture = require('../../fixture').clayItem;
|
var clayItemFixture = require('../../fixture').clayItem;
|
||||||
var configItemFixture = require('../../fixture').configItem;
|
var configItemFixture = require('../../fixture').configItem;
|
||||||
var componentRegistry = require('../../../src/scripts/lib/component-registry');
|
var componentRegistry = require('../../../src/scripts/lib/component-registry');
|
||||||
@@ -98,6 +99,7 @@ describe('ClayItem', function() {
|
|||||||
var initializeSpy = sinon.spy(componentRegistry.select, 'initialize');
|
var initializeSpy = sinon.spy(componentRegistry.select, 'initialize');
|
||||||
var clayItem = clayItemFixture('select').initialize();
|
var clayItem = clayItemFixture('select').initialize();
|
||||||
assert(initializeSpy.alwaysCalledOn(clayItem));
|
assert(initializeSpy.alwaysCalledOn(clayItem));
|
||||||
|
assert(initializeSpy.alwaysCalledWith(minified));
|
||||||
initializeSpy.restore();
|
initializeSpy.restore();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user