Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@
"no-with": 2,
"one-var": 0,
"operator-assignment": 0,
"operator-linebreak": [2, "after"],
"padded-blocks": 0,
"quote-props": 0,
"quotes": [2, "single", "avoid-escape"],
Expand Down
17 changes: 10 additions & 7 deletions dist/wurd.cjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,6 @@ class Block {
this.wurd = wurd;
this.path = path;

// Private shortcut to the main content getter
// TODO: Make a proper private variable
// See http://voidcanvas.com/es6-private-variables/ - but could require Babel Polyfill to be included
this._get = wurd.store.get.bind(wurd.store);

// Bind methods to the instance to enable 'this' to be available
// to own methods and added helper methods;
// This also allows object destructuring, for example:
Expand Down Expand Up @@ -168,13 +163,13 @@ class Block {
* @return {Mixed}
*/
get(path) {
const result = this._get(this.id(path));
const result = this.wurd.store.get(this.id(path));

// If an item is missing, check that the section has been loaded
if (typeof result === 'undefined' && this.wurd.draft) {
const section = path.split('.')[0];

if (!this._get(section)) {
if (!this.wurd.store.get(section)) {
console.warn(`Tried to access unloaded section: ${section}`);
}
}
Expand Down Expand Up @@ -474,6 +469,14 @@ class Wurd {
// Pass main content Block to callbacks
if (onLoad) onLoad(content);

return content;
})
.catch(err => {
if (debug) console.info('Wurd: load error:', err);

// If content fails to load (wurd app offline), still return cache
if (onLoad) onLoad(content);

return content;
});
}
Expand Down
17 changes: 10 additions & 7 deletions dist/wurd.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,6 @@ class Block {
this.wurd = wurd;
this.path = path;

// Private shortcut to the main content getter
// TODO: Make a proper private variable
// See http://voidcanvas.com/es6-private-variables/ - but could require Babel Polyfill to be included
this._get = wurd.store.get.bind(wurd.store);

// Bind methods to the instance to enable 'this' to be available
// to own methods and added helper methods;
// This also allows object destructuring, for example:
Expand Down Expand Up @@ -166,13 +161,13 @@ class Block {
* @return {Mixed}
*/
get(path) {
const result = this._get(this.id(path));
const result = this.wurd.store.get(this.id(path));

// If an item is missing, check that the section has been loaded
if (typeof result === 'undefined' && this.wurd.draft) {
const section = path.split('.')[0];

if (!this._get(section)) {
if (!this.wurd.store.get(section)) {
console.warn(`Tried to access unloaded section: ${section}`);
}
}
Expand Down Expand Up @@ -472,6 +467,14 @@ class Wurd {
// Pass main content Block to callbacks
if (onLoad) onLoad(content);

return content;
})
.catch(err => {
if (debug) console.info('Wurd: load error:', err);

// If content fails to load (wurd app offline), still return cache
if (onLoad) onLoad(content);

return content;
});
}
Expand Down
Loading