Skip to content

Commit a5edc93

Browse files
committed
fix vue material instance on non commonjs env #220
1 parent ddd2010 commit a5edc93

File tree

5 files changed

+16
-8
lines changed

5 files changed

+16
-8
lines changed

docs/changelog.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<section>
22
<h2 class="md-headline">
3-
<a href="https://vuematerial.github.io/releases/v0.5.0/">v0.5.0 - New Grid System Engine!</a>
3+
<a href="https://vuematerial.github.io/">v0.5.0 - New Grid System Engine!</a>
44
</h2>
55

66
<h3 class="md-title">New Components:</h3>

docs/src/components/PageContent.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@
125125
this.availableDocs = versions;
126126
},
127127
setCurrentByLocation() {
128-
let normalizedPathname = location.pathname.replace(/\/|v/g, '');
128+
let normalizedPathname = location.pathname.replace(/\/|releases\/v/g, '');
129129
130130
if (normalizedPathname && this.availableDocs.indexOf(normalizedPathname) >= 0) {
131131
this.currentDocs = normalizedPathname;

docs/src/pages/themes/Configuration.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,10 @@
102102
<code-block lang="javascript">
103103
Vue.material.setCurrentTheme('about')
104104
</code-block>
105+
Or inside a Vue instance:
106+
<code-block lang="javascript">
107+
this.$material.setCurrentTheme('about')
108+
</code-block>
105109
</section>
106110

107111
<section>

src/core/components/mdTheme/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,4 +157,6 @@ export default function install(Vue) {
157157
});
158158

159159
Vue.component('md-theme', MdTheme);
160+
161+
Vue.prototype.$material = Vue.material;
160162
}

src/core/components/mdTheme/mixin.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import Vue from 'vue';
2-
31
export default {
42
props: {
53
mdTheme: String
@@ -29,17 +27,21 @@ export default {
2927
let theme = this.closestThemedParent.mdTheme;
3028

3129
if (!theme) {
32-
theme = this.closestThemedParent.mdName;
30+
if (this.closestThemedParent) {
31+
theme = this.closestThemedParent.mdName;
32+
} else {
33+
theme = this.$material.currentTheme;
34+
}
3335
}
3436

35-
return 'md-theme-' + (theme || Vue.material.currentTheme);
37+
return 'md-theme-' + theme;
3638
}
3739
},
3840
mounted() {
3941
this.closestThemedParent = this.getClosestThemedParent(this.$parent);
4042

41-
if (!Vue.material.currentTheme) {
42-
Vue.material.setCurrentTheme('default');
43+
if (!this.$material.currentTheme) {
44+
this.$material.setCurrentTheme('default');
4345
}
4446
}
4547
};

0 commit comments

Comments
 (0)