-
Notifications
You must be signed in to change notification settings - Fork 615
Commit
* Upgrade to webpack 4 * Clean up stencil bootstrap * Simplify interface for PageManager and get rid of async library dependency * Get rid of html5-history-api library dependency (no longer needed) * Get rid of fastclick library dependency (no longer needed) * Upgrade several babel dependencies * Separate webpack config into common, dev, prod, and add npm scripts to build * Get rid of minifications in babel loader, instead rely on webpack * Get rid of LoaderOptionsPlugin * Get rid of CommonsChunkPlugin (webpack 4 will automaticaly do this for prod)
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
language: node_js | ||
node_js: | ||
- 4 | ||
- 6 | ||
sudo: required | ||
dist: trusty | ||
install: | ||
- bundle install | ||
- npm install -g grunt-cli | ||
- npm install -g bigcommerce/stencil-cli | ||
- npm install | ||
- bundle install | ||
- npm install -g grunt-cli | ||
- npm install -g bigcommerce/stencil-cli | ||
- npm install | ||
script: | ||
- grunt check | ||
- stencil bundle | ||
- grunt check | ||
- stencil bundle |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,14 +8,14 @@ import { classifyForm, Validators, insertStateHiddenField } from './common/form- | |
import swal from 'sweetalert2'; | ||
|
||
export default class Account extends PageManager { | ||
constructor() { | ||
super(); | ||
constructor(context) { | ||
super(context); | ||
|
||
this.$state = $('[data-field-type="State"]'); | ||
this.$body = $('body'); | ||
} | ||
|
||
loaded(next) { | ||
onReady() { | ||
const $editAccountForm = classifyForm('form[data-edit-account-form]'); | ||
const $addressForm = classifyForm('form[data-address-form]'); | ||
const $inboxForm = classifyForm('form[data-inbox-form]'); | ||
|
@@ -27,7 +27,7 @@ export default class Account extends PageManager { | |
this.passwordRequirements = this.context.passwordRequirements; | ||
|
||
// Instantiates wish list JS | ||
this.wishlist = new Wishlist(); | ||
Wishlist.load(); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
mattolson
Author
Contributor
|
||
|
||
if ($editAccountForm.length) { | ||
this.registerEditAccountValidation($editAccountForm); | ||
|
@@ -67,8 +67,6 @@ export default class Account extends PageManager { | |
} | ||
|
||
this.bindDeleteAddress(); | ||
|
||
next(); | ||
} | ||
|
||
/** | ||
|
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -17,7 +17,8 @@ export default class ProductDetails { | |||
this.imageGallery.init(); | ||||
this.listenQuantityChange(); | ||||
this.initRadioAttributes(); | ||||
this.wishlist = new Wishlist().load(); | ||||
|
||||
Wishlist.load(); | ||||
This comment has been minimized.
Sorry, something went wrong.
jbruni
Contributor
|
const confirmed = window.confirm(this.context.wishlistDelete); |
This code snippet is normally only activated from the account > wishlist page, where the Wishlist class is the main page class.
But here, the line being discussed is at assets/js/theme/common/product-details.js
file, right?
So... to understand clearly what is the issue, you can add this code as the first line of templates/components/products/product-view.html
:
<button data-wishlist-delete>Delete All Wishlists</button>
Then, visit any product page, and click this "Delete All Wishlists" button. You will see the following in console:
What is going on? Like I said, this.context
is undefined
inside the WishList class instance.
Why? Because load
has been called without any parameters. But load
expects context
as parameter. It is missing.
In default Cornerstone, this won't be an issue, because, as said above, this.context
is almost not used (in WishList class). The only time it is used, it is in a scenario where this.context
is available. But any customization may expect to have this.context
with the context in there in all scenarios (product page, account page).
Please let me know if my point is clear now.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,22 @@ | ||
import async from 'async'; | ||
import $ from 'jquery'; | ||
|
||
export default class PageManager { | ||
constructor(context) { | ||
this.context = context; | ||
} | ||
|
||
before(next) { | ||
next(); | ||
} | ||
|
||
loaded(next) { | ||
next(); | ||
type() { | ||
return this.constructor.name; | ||
} | ||
|
||
after(next) { | ||
next(); | ||
onReady() { | ||
} | ||
|
||
type() { | ||
return this.constructor.name; | ||
} | ||
static load(context) { | ||
const page = new this(context); | ||
|
||
load() { | ||
async.series([ | ||
this.before.bind(this), // Executed first after constructor() | ||
this.loaded.bind(this), // Main module logic | ||
this.after.bind(this), // Clean up method that can be overridden for cleanup. | ||
], (err) => { | ||
if (err) { | ||
throw new Error(err); | ||
} | ||
$(document).ready(() => { | ||
page.onReady.bind(page)(); | ||
}); | ||
} | ||
} |
@mattolson - Shouldn't it be
Wishlist.load(this.context);
?