Skip to content

Commit

Permalink
Add before destroy teardown
Browse files Browse the repository at this point in the history
  • Loading branch information
francoislevesque committed Mar 8, 2022
1 parent c320b97 commit 93590bd
Show file tree
Hide file tree
Showing 12 changed files with 39,228 additions and 9,342 deletions.
28 changes: 28 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
module.exports = {
root: true,
env: {
browser: true,
node: true,
},
extends: [
"eslint:recommended",
"plugin:vue/recommended",
],
parserOptions: {
ecmaVersion: 2020,
},
rules: {
indent: ["error", 2],
quotes: ["error", "double"],
semi: ["error", "always"],
"no-console": process.env.NODE_ENV === "production" ? "warn" : "off",
"no-debugger": process.env.NODE_ENV === "production" ? "warn" : "off",
"no-undef": 0,
"no-unused-vars": ["error", { "args": "none" }],
"vue/component-definition-name-casing": ["error", "kebab-case"],
"keyword-spacing": ["error"],
"vue/multi-word-component-names": ["error", {
"ignores": ["Payment"]
}]
},
};
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
// TODO: release log here ...
2.2.0

teardown() is called when the component is destroyed (https://github.com/francoislevesque/vue-braintree/issues/42)
4 changes: 2 additions & 2 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {
presets: [
'@vue/cli-plugin-babel/preset'
"@vue/cli-plugin-babel/preset"
]
}
};
24 changes: 20 additions & 4 deletions demo/Demo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
<h1>Braintree Demo</h1>

<v-braintree
v-if="showDropIn"
authorization="sandbox_9q89mhss_x742hzxzgx6gk233"
:paypal="{flow: 'vault'}"
:three-d-secure="true"
:three-d-secure="false"
:three-d-secure-parameters="{
amount: 100,
email: '[email protected]',
Expand Down Expand Up @@ -39,6 +40,13 @@
<button class="btn">
Clear Payment Selection
</button>

<br>
<br>

<button @click="deleteInstance" class="btn btn-danger">
Delete instance
</button>
</div>
</template>

Expand All @@ -47,26 +55,34 @@ export default {
name: 'demo',
data () {
return {
instance: null
instance: null,
showDropIn: true,
}
},
methods: {
onLoad (instance) {
this.instance = instance;
},
onLoadFail (instance) {
alert('load fail');
console.error('Load fail', instance);
},
onSuccess (payload) {
console.log("Success!", payload.nonce);
},
onError (error) {
console.log("Error!", error);
console.error("Error:", error);
},
clearPaymentSelection () {
if (this.instance != null) {
this.instance.clearSelectedPaymentMethod();
}
},
deleteInstance() {
this.showDropIn = false;
setInterval(() => {
this.showDropIn = true;
}, 1000);
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
module.exports = {
preset: '@vue/cli-plugin-unit-jest',
preset: "@vue/cli-plugin-unit-jest",
collectCoverage: true,
collectCoverageFrom: [
'src/**/*.{js,vue}',
'!src/main.js',
"src/**/*.{js,vue}",
"!src/main.js",
],
}
};
Loading

0 comments on commit 93590bd

Please sign in to comment.