Skip to content

Commit

Permalink
Fix regressions
Browse files Browse the repository at this point in the history
  • Loading branch information
artf committed Sep 4, 2017
1 parent 7868c4b commit ab7ffe1
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 23 deletions.
19 changes: 6 additions & 13 deletions src/asset_manager/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,30 +202,23 @@ module.exports = () => {
},

/**
* Load data from the passed object, if the object is empty will try to fetch them
* autonomously from the storage manager.
* The fetched data will be added to the collection
* Load data from the passed object.
* The fetched data will be added to the collection.
* @param {Object} data Object of data to load
* @return {Object} Loaded assets
* @example
* var assets = assetManager.load();
* // The format below will be used by the editor model
* // to load automatically all the stuff
* var assets = assetManager.load({
* assets: [...]
* })
*
*/
load(data) {
var d = data || '';
var name = this.storageKey;
if(!d && c.stm)
d = c.stm.load(name);
var assets = d[name] || [];
load(data = {}) {
const name = this.storageKey;
let assets = data[name] || [];

if (typeof assets == 'string') {
try {
assets = JSON.parse(d[name]);
assets = JSON.parse(data[name]);
} catch(err) {}
}

Expand Down
1 change: 0 additions & 1 deletion src/editor/model/Editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,6 @@ module.exports = Backbone.Model.extend({
*/
load(clb = null) {
this.getCacheLoad(1, (res) => {
console.log('LOADED in em.load', res);
this.get('storables').forEach(module => module.load(res));
clb && clb(res);
});
Expand Down
1 change: 1 addition & 0 deletions src/parser/model/ParserCss.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ module.exports = config => ({
var style = {};
for (var j = 0, len2 = stl.length; j < len2; j++) {
var propName = stl[j];
//console.log('Style', stl, propName, ': ', stl.getPropertyValue(propName));
var important = stl.getPropertyPriority(propName);
style[propName] = stl[propName] +
(important ? ' !' + important : '');
Expand Down
2 changes: 1 addition & 1 deletion test/specs/asset_manager/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ describe('Asset Manager', () => {
obj.add(imgObj);
obj.store();
obj.remove(imgObj.src);
obj.load();
obj.load({assets: storage['gjs-assets']});
var asset = obj.get(imgObj.src);
expect(asset.get('width')).toEqual(imgObj.width);
expect(asset.get('height')).toEqual(imgObj.height);
Expand Down
5 changes: 3 additions & 2 deletions test/specs/grapesjs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,9 @@ describe('GrapesJS', () => {
var editor = obj.init(config);
editor.setComponents(htmlString);
editor.store();
var data = editor.load();
expect(data.html).toEqual(htmlString);
editor.load((data) => {
expect(data.html).toEqual(htmlString);
});
});

it('Execute plugins with custom options', () => {
Expand Down
11 changes: 7 additions & 4 deletions test/specs/storage_manager/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ describe('Storage Manager', () => {
});

it('Load do not execute if empty', () => {
expect(obj.load(['item'])).toEqual({});
obj.load(['item'], (res) => {
expect(res).toEqual({});
});
});

it('Load default storages ', () => {
Expand Down Expand Up @@ -106,9 +108,10 @@ describe('Storage Manager', () => {
data2[id + 'item2'] = 'testData2';

obj.store(data);
var load = obj.load(['item', 'item2']);
expect(storeValue).toEqual(data2);
expect(load).toEqual(data);
obj.load(['item', 'item2'], (res) => {
expect(storeValue).toEqual(data2);
expect(res).toEqual(data);
});
});

});
Expand Down
2 changes: 0 additions & 2 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
//webpack --display-reasons
//Remove jquery https://github.com/webpack/webpack/issues/1275
var webpack = require('webpack');
var pkg = require('./package.json');
var env = process.env.WEBPACK_ENV;
Expand Down

0 comments on commit ab7ffe1

Please sign in to comment.