@@ -2770,7 +2770,7 @@ function isRefSelector (refOptionsObject) {
27702770 return isValid
27712771}
27722772
2773- //
2773+ //
27742774
27752775var selectorTypes = {
27762776 DOM_SELECTOR : 'DOM_SELECTOR' ,
@@ -2861,7 +2861,7 @@ function removeDuplicateNodes (vNodes) {
28612861 return uniqueNodes
28622862}
28632863
2864- //
2864+ //
28652865
28662866function nodeMatchesSelector ( node , selector ) {
28672867 return node . elm && node . elm . getAttribute && node . elm . matches ( selector )
@@ -2887,7 +2887,7 @@ function findVNodesByRef (vNode, refName) {
28872887 return removeDuplicateNodes ( mainVNodeFilteredNodes )
28882888}
28892889
2890- //
2890+ //
28912891
28922892
28932893
@@ -2903,6 +2903,18 @@ WrapperArray.prototype.at = function at (index) {
29032903 return this . wrappers [ index ]
29042904} ;
29052905
2906+ WrapperArray . prototype . attributes = function attributes ( ) {
2907+ this . throwErrorIfWrappersIsEmpty ( 'attributes' ) ;
2908+
2909+ throwError ( 'attributes must be called on a single wrapper, use at(i) to access a wrapper' ) ;
2910+ } ;
2911+
2912+ WrapperArray . prototype . classes = function classes ( ) {
2913+ this . throwErrorIfWrappersIsEmpty ( 'classes' ) ;
2914+
2915+ throwError ( 'classes must be called on a single wrapper, use at(i) to access a wrapper' ) ;
2916+ } ;
2917+
29062918WrapperArray . prototype . contains = function contains ( selector ) {
29072919 this . throwErrorIfWrappersIsEmpty ( 'contains' ) ;
29082920
@@ -2990,6 +3002,12 @@ WrapperArray.prototype.name = function name () {
29903002 throwError ( 'name must be called on a single wrapper, use at(i) to access a wrapper' ) ;
29913003} ;
29923004
3005+ WrapperArray . prototype . props = function props ( ) {
3006+ this . throwErrorIfWrappersIsEmpty ( 'props' ) ;
3007+
3008+ throwError ( 'props must be called on a single wrapper, use at(i) to access a wrapper' ) ;
3009+ } ;
3010+
29933011WrapperArray . prototype . text = function text ( ) {
29943012 this . throwErrorIfWrappersIsEmpty ( 'text' ) ;
29953013
@@ -3053,6 +3071,14 @@ ErrorWrapper.prototype.at = function at () {
30533071 throwError ( ( "find did not return " + ( this . selector ) + ", cannot call at() on empty Wrapper" ) ) ;
30543072} ;
30553073
3074+ ErrorWrapper . prototype . attributes = function attributes ( ) {
3075+ throwError ( ( "find did not return " + ( this . selector ) + ", cannot call attributes() on empty Wrapper" ) ) ;
3076+ } ;
3077+
3078+ ErrorWrapper . prototype . classes = function classes ( ) {
3079+ throwError ( ( "find did not return " + ( this . selector ) + ", cannot call classes() on empty Wrapper" ) ) ;
3080+ } ;
3081+
30563082ErrorWrapper . prototype . contains = function contains ( ) {
30573083 throwError ( ( "find did not return " + ( this . selector ) + ", cannot call contains() on empty Wrapper" ) ) ;
30583084} ;
@@ -3113,6 +3139,10 @@ ErrorWrapper.prototype.name = function name () {
31133139 throwError ( ( "find did not return " + ( this . selector ) + ", cannot call name() on empty Wrapper" ) ) ;
31143140} ;
31153141
3142+ ErrorWrapper . prototype . props = function props ( ) {
3143+ throwError ( ( "find did not return " + ( this . selector ) + ", cannot call props() on empty Wrapper" ) ) ;
3144+ } ;
3145+
31163146ErrorWrapper . prototype . text = function text ( ) {
31173147 throwError ( ( "find did not return " + ( this . selector ) + ", cannot call text() on empty Wrapper" ) ) ;
31183148} ;
@@ -3159,6 +3189,41 @@ Wrapper.prototype.at = function at () {
31593189 throwError ( 'at() must be called on a WrapperArray' ) ;
31603190} ;
31613191
3192+ /**
3193+ * Returns an Object containing all the attribute/value pairs on the element.
3194+ */
3195+ Wrapper . prototype . attributes = function attributes ( ) {
3196+ var attributes = [ ] . concat ( this . element . attributes ) ; // NameNodeMap is not iterable
3197+ var attributeMap = { } ;
3198+ attributes . forEach ( function ( att ) {
3199+ attributeMap [ att . localName ] = att . value ;
3200+ } ) ;
3201+ return attributeMap
3202+ } ;
3203+
3204+ /**
3205+ * Returns an Array containing all the classes on the element
3206+ */
3207+ Wrapper . prototype . classes = function classes ( ) {
3208+ var this$1 = this ;
3209+
3210+ var classes = [ ] . concat ( this . element . classList ) ;
3211+ // Handle converting cssmodules identifiers back to the original class name
3212+ if ( this . vm && this . vm . $style ) {
3213+ var cssModuleIdentifiers = { } ;
3214+ var moduleIdent ;
3215+ Object . keys ( this . vm . $style ) . forEach ( function ( key ) {
3216+ // $FlowIgnore : Flow thinks vm is a property
3217+ moduleIdent = this$1 . vm . $style [ key ] ;
3218+ // CSS Modules may be multi-class if they extend others. Extended classes should be already present in $style.
3219+ moduleIdent = moduleIdent . split ( ' ' ) [ 0 ] ;
3220+ cssModuleIdentifiers [ moduleIdent ] = key ;
3221+ } ) ;
3222+ classes = classes . map ( function ( className ) { return cssModuleIdentifiers [ className ] || className ; } ) ;
3223+ }
3224+ return classes
3225+ } ;
3226+
31623227/**
31633228 * Checks if wrapper contains provided selector.
31643229 */
@@ -3188,10 +3253,13 @@ Wrapper.prototype.contains = function contains (selector) {
31883253/**
31893254 * Returns an object containing custom events emitted by the Wrapper vm
31903255 */
3191- Wrapper . prototype . emitted = function emitted ( ) {
3256+ Wrapper . prototype . emitted = function emitted ( event ) {
31923257 if ( ! this . _emitted && ! this . vm ) {
31933258 throwError ( 'wrapper.emitted() can only be called on a Vue instance' ) ;
31943259 }
3260+ if ( event ) {
3261+ return this . _emitted [ event ]
3262+ }
31953263 return this . _emitted
31963264} ;
31973265
@@ -3436,6 +3504,24 @@ Wrapper.prototype.name = function name () {
34363504 return this . vnode . tag
34373505} ;
34383506
3507+ /**
3508+ * Returns an Object containing the prop name/value pairs on the element
3509+ */
3510+ Wrapper . prototype . props = function props ( ) {
3511+ if ( ! this . isVueComponent ) {
3512+ throwError ( 'wrapper.props() must be called on a Vue instance' ) ;
3513+ }
3514+ // $props object does not exist in Vue 2.1.x, so use $options.propsData instead
3515+ var _props ;
3516+ if ( this . vm && this . vm . $options && this . vm . $options . propsData ) {
3517+ _props = this . vm . $options . propsData ;
3518+ } else {
3519+ // $FlowIgnore
3520+ _props = this . vm . $props ;
3521+ }
3522+ return _props || { } // Return an empty object if no props exist
3523+ } ;
3524+
34393525/**
34403526 * Sets vm data
34413527 */
@@ -3949,7 +4035,7 @@ var config = {
39494035 }
39504036} ;
39514037
3952- //
4038+ //
39534039function getStubs ( optionStubs ) {
39544040 if ( optionStubs || Object . keys ( config . stubs ) . length > 0 ) {
39554041 if ( Array . isArray ( optionStubs ) ) {
@@ -3989,7 +4075,7 @@ function deleteMountingOptions (options) {
39894075 delete options . listeners ;
39904076}
39914077
3992- //
4078+ //
39934079
39944080function isValidSlot ( slot ) {
39954081 return Array . isArray ( slot ) || ( slot !== null && typeof slot === 'object' ) || typeof slot === 'string'
@@ -4092,7 +4178,7 @@ function createConstructor (
40924178 return vm
40934179}
40944180
4095- //
4181+ //
40964182
40974183function createElement ( ) {
40984184 if ( document ) {
@@ -4120,7 +4206,7 @@ if (!Element.prototype.matches) {
41204206 } ;
41214207}
41224208
4123- //
4209+ //
41244210
41254211Vue . config . productionTip = false ;
41264212Vue . config . errorHandler = errorHandler ;
@@ -4147,7 +4233,7 @@ function mount (component, options) {
41474233 return new VueWrapper ( vm , { attachedToDocument : ! ! options . attachToDocument } )
41484234}
41494235
4150- //
4236+ //
41514237
41524238function shallow ( component , options ) {
41534239 if ( options === void 0 ) options = { } ;
0 commit comments