Skip to content

Commit 5e6c310

Browse files
hosmelqAkryum
authored andcommitted
feat: show injected properties (#659)
* show injected properties * test: injected props
1 parent a5095c6 commit 5e6c310

File tree

3 files changed

+44
-2
lines changed

3 files changed

+44
-2
lines changed

cypress/integration/components-tab.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,4 +92,16 @@ suite('components tab', () => {
9292
cy.get('.instance .self .attr-title').contains('key')
9393
cy.get('.instance .self .attr-value').contains('1')
9494
})
95+
96+
it('should display injected props', () => {
97+
cy.get('.left .search input').clear().type('Mine')
98+
cy.get('.instance').eq(1).click()
99+
cy.get('.right .data-wrapper').then(el => {
100+
expect(el.text()).to.contain('injected')
101+
expect(el.text()).to.contain('answer:42')
102+
expect(el.text()).to.contain('foo:"bar"')
103+
expect(el.text()).to.contain('noop:ƒ noop(a, b, c)')
104+
})
105+
cy.get('.left .search input').clear()
106+
})
95107
})

shells/dev/target/Other.vue

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<div>
33
Other {{ id }}
4-
<mine></mine>
4+
<mine/>
55
</div>
66
</template>
77

@@ -18,8 +18,13 @@ const computedPropMixin = {
1818
1919
export default {
2020
name: 'other-with-mine',
21-
props: ['id'],
2221
mixins: [computedPropMixin],
22+
provide: {
23+
foo: 'bar',
24+
noop: (a, b, c) => {},
25+
answer: 42
26+
},
27+
props: ['id'],
2328
data () {
2429
const a = { c: function () {} }
2530
a.a = a
@@ -32,6 +37,7 @@ export default {
3237
},
3338
components: {
3439
mine: {
40+
inject: ['foo', 'noop', 'answer'],
3541
render: h => h('div', { class: 'mine' }, 'mine'),
3642
data () {
3743
return {

src/backend/index.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,7 @@ function getInstanceState (instance) {
378378
return processProps(instance).concat(
379379
processState(instance),
380380
processComputed(instance),
381+
processInjected(instance),
381382
processRouteContext(instance),
382383
processVuexGetters(instance),
383384
processFirebaseBindings(instance),
@@ -563,6 +564,29 @@ function processComputed (instance) {
563564
return computed
564565
}
565566

567+
/**
568+
* Process Vuex getters.
569+
*
570+
* @param {Vue} instance
571+
* @return {Array}
572+
*/
573+
574+
function processInjected (instance) {
575+
const injected = instance.$options.inject
576+
577+
if (injected) {
578+
return Object.keys(injected).map(key => {
579+
return {
580+
key,
581+
type: 'injected',
582+
value: instance[key]
583+
}
584+
})
585+
} else {
586+
return []
587+
}
588+
}
589+
566590
/**
567591
* Process possible vue-router $route context
568592
*

0 commit comments

Comments
 (0)