Skip to content

Commit

Permalink
feat: Add $attrs to StateInspector, closes vuejs#734 (vuejs#861)
Browse files Browse the repository at this point in the history
This PR fixes vuejs#734 


Co-authored-by: Guillaume Chau <alphadelta.fg@gmail.com>
  • Loading branch information
2 people authored and iksim committed Apr 18, 2019
1 parent b05ed98 commit ea8a00e
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 3 deletions.
9 changes: 9 additions & 0 deletions cypress/integration/components-tab.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,13 @@ suite('components tab', () => {
expect(el.text()).to.contain('tester:<p id="testing"')
})
})

it('should display $attrs', () => {
cy.get('.instance .instance:nth-child(2) .arrow-wrapper').click()
cy.get('.instance .instance .instance:nth-child(1) .item-name').click()
cy.get('.right .data-wrapper').then(el => {
expect(el.text()).to.contain('$attrs')
expect(el.text()).to.contain('attr:"some-attr"')
})
})
})
1 change: 1 addition & 0 deletions shells/dev/target/Other.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const computedPropMixin = {
export default {
name: 'other-with-mine',
inheritAttrs: false,
mixins: [computedPropMixin],
provide: {
foo: 'bar',
Expand Down
2 changes: 1 addition & 1 deletion shells/dev/target/Target.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<button class="add" @mouseup="add">Add 3</button>
<button class="remove" @mousedown="rm">Remove</button>
<input v-model="localMsg">
<other v-for="item in items" :key="item" :id="item"></other>
<other v-for="item in items" :key="item" :id="item" attr="some-attr"></other>
<div>
<button
class="inspect"
Expand Down
13 changes: 12 additions & 1 deletion src/backend/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,8 @@ function getInstanceState (instance) {
processRouteContext(instance),
processVuexGetters(instance),
processFirebaseBindings(instance),
processObservables(instance)
processObservables(instance),
processAttrs(instance)
)
}

Expand Down Expand Up @@ -637,6 +638,16 @@ function processProps (instance) {
}
}

function processAttrs (instance) {
return Object.entries(instance.$attrs).map(([key, value]) => {
return {
type: '$attrs',
key,
value
}
})
}

/**
* Convert prop type constructor to string.
*
Expand Down
3 changes: 2 additions & 1 deletion src/devtools/components/StateInspector.vue
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ const keyOrder = {
getters: 3,
mutation: 1,
'vuex bindings': 5,
$refs: 6
$refs: 6,
$attrs: 7
}
export default {
Expand Down

0 comments on commit ea8a00e

Please sign in to comment.