Skip to content

Commit 6338a63

Browse files
simsim0709Guillaume Chau
authored andcommitted
feat: Add $attrs to StateInspector, closes #734 (#861)
This PR fixes #734 Co-authored-by: Guillaume Chau <[email protected]>
1 parent 8eebefe commit 6338a63

File tree

5 files changed

+25
-3
lines changed

5 files changed

+25
-3
lines changed

Diff for: cypress/integration/components-tab.js

+9
Original file line numberDiff line numberDiff line change
@@ -137,4 +137,13 @@ suite('components tab', () => {
137137
expect(el.text()).to.contain('tester:<p id="testing"')
138138
})
139139
})
140+
141+
it('should display $attrs', () => {
142+
cy.get('.instance .instance:nth-child(2) .arrow-wrapper').click()
143+
cy.get('.instance .instance .instance:nth-child(1) .item-name').click()
144+
cy.get('.right .data-wrapper').then(el => {
145+
expect(el.text()).to.contain('$attrs')
146+
expect(el.text()).to.contain('attr:"some-attr"')
147+
})
148+
})
140149
})

Diff for: shells/dev/target/Other.vue

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const computedPropMixin = {
1818
1919
export default {
2020
name: 'other-with-mine',
21+
inheritAttrs: false,
2122
mixins: [computedPropMixin],
2223
provide: {
2324
foo: 'bar',

Diff for: shells/dev/target/Target.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<button class="add" @mouseup="add">Add 3</button>
99
<button class="remove" @mousedown="rm">Remove</button>
1010
<input v-model="localMsg">
11-
<other v-for="item in items" :key="item" :id="item"></other>
11+
<other v-for="item in items" :key="item" :id="item" attr="some-attr"></other>
1212
<div>
1313
<button
1414
class="inspect"

Diff for: src/backend/index.js

+12-1
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,8 @@ function getInstanceState (instance) {
539539
processRouteContext(instance),
540540
processVuexGetters(instance),
541541
processFirebaseBindings(instance),
542-
processObservables(instance)
542+
processObservables(instance),
543+
processAttrs(instance)
543544
)
544545
}
545546

@@ -637,6 +638,16 @@ function processProps (instance) {
637638
}
638639
}
639640

641+
function processAttrs (instance) {
642+
return Object.entries(instance.$attrs).map(([key, value]) => {
643+
return {
644+
type: '$attrs',
645+
key,
646+
value
647+
}
648+
})
649+
}
650+
640651
/**
641652
* Convert prop type constructor to string.
642653
*

Diff for: src/devtools/components/StateInspector.vue

+2-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ const keyOrder = {
6565
getters: 3,
6666
mutation: 1,
6767
'vuex bindings': 5,
68-
$refs: 6
68+
$refs: 6,
69+
$attrs: 7
6970
}
7071
7172
export default {

0 commit comments

Comments
 (0)