@@ -6,9 +6,9 @@ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'defau
6
6
7
7
var Vue = _interopDefault ( require ( 'vue' ) ) ;
8
8
var vueTemplateCompiler = require ( 'vue-template-compiler' ) ;
9
- var vueServerRenderer = require ( 'vue-server-renderer' ) ;
10
9
var testUtils = require ( '@vue/test-utils' ) ;
11
10
var testUtils__default = _interopDefault ( testUtils ) ;
11
+ var vueServerRenderer = require ( 'vue-server-renderer' ) ;
12
12
var cheerio = _interopDefault ( require ( 'cheerio' ) ) ;
13
13
14
14
//
@@ -1701,6 +1701,18 @@ var semver_40 = semver.prerelease;
1701
1701
var semver_41 = semver . intersects ;
1702
1702
var semver_42 = semver . coerce ;
1703
1703
1704
+ var VUE_VERSION = Number (
1705
+ ( ( Vue . version . split ( '.' ) [ 0 ] ) + "." + ( Vue . version . split ( '.' ) [ 1 ] ) )
1706
+ ) ;
1707
+
1708
+ var BEFORE_RENDER_LIFECYCLE_HOOK = semver . gt ( Vue . version , '2.1.8' )
1709
+ ? 'beforeCreate'
1710
+ : 'beforeMount' ;
1711
+
1712
+ var CREATE_ELEMENT_ALIAS = semver . gt ( Vue . version , '2.1.5' )
1713
+ ? '_c'
1714
+ : '_h' ;
1715
+
1704
1716
//
1705
1717
1706
1718
function throwError ( msg ) {
@@ -1768,6 +1780,15 @@ var isPhantomJS = UA && UA.includes && UA.match(/phantomjs/i);
1768
1780
var isEdge = UA && UA . indexOf ( 'edge/' ) > 0 ;
1769
1781
var isChrome = UA && / c h r o m e \/ \d + / . test ( UA ) && ! isEdge ;
1770
1782
1783
+ function warnDeprecated ( method , fallback ) {
1784
+ if ( fallback === void 0 ) fallback = '' ;
1785
+
1786
+ if ( ! testUtils . config . showDeprecationWarnings ) { return }
1787
+ var msg = method + " is deprecated and will removed in the next major version" ;
1788
+ if ( fallback ) { msg += " " + fallback ; }
1789
+ warn ( msg ) ;
1790
+ }
1791
+
1771
1792
//
1772
1793
1773
1794
function addMocks (
@@ -1822,18 +1843,6 @@ function addEventLogger(_Vue) {
1822
1843
} ) ;
1823
1844
}
1824
1845
1825
- var VUE_VERSION = Number (
1826
- ( ( Vue . version . split ( '.' ) [ 0 ] ) + "." + ( Vue . version . split ( '.' ) [ 1 ] ) )
1827
- ) ;
1828
-
1829
- var BEFORE_RENDER_LIFECYCLE_HOOK = semver . gt ( Vue . version , '2.1.8' )
1830
- ? 'beforeCreate'
1831
- : 'beforeMount' ;
1832
-
1833
- var CREATE_ELEMENT_ALIAS = semver . gt ( Vue . version , '2.1.5' )
1834
- ? '_c'
1835
- : '_h' ;
1836
-
1837
1846
function addStubs ( _Vue , stubComponents ) {
1838
1847
var obj ;
1839
1848
@@ -1846,6 +1855,33 @@ function addStubs(_Vue, stubComponents) {
1846
1855
1847
1856
//
1848
1857
1858
+ function isDomSelector ( selector ) {
1859
+ if ( typeof selector !== 'string' ) {
1860
+ return false
1861
+ }
1862
+
1863
+ try {
1864
+ if ( typeof document === 'undefined' ) {
1865
+ throwError (
1866
+ "mount must be run in a browser environment like " +
1867
+ "PhantomJS, jsdom or chrome"
1868
+ ) ;
1869
+ }
1870
+ } catch ( error ) {
1871
+ throwError (
1872
+ "mount must be run in a browser environment like " +
1873
+ "PhantomJS, jsdom or chrome"
1874
+ ) ;
1875
+ }
1876
+
1877
+ try {
1878
+ document . querySelector ( selector ) ;
1879
+ return true
1880
+ } catch ( error ) {
1881
+ return false
1882
+ }
1883
+ }
1884
+
1849
1885
function isVueComponent ( c ) {
1850
1886
if ( isConstructor ( c ) ) {
1851
1887
return true
@@ -1911,6 +1947,14 @@ function isPlainObject(c) {
1911
1947
return Object . prototype . toString . call ( c ) === '[object Object]'
1912
1948
}
1913
1949
1950
+ function isHTMLElement ( c ) {
1951
+ if ( typeof HTMLElement === 'undefined' ) {
1952
+ return false
1953
+ }
1954
+ // eslint-disable-next-line no-undef
1955
+ return c instanceof HTMLElement
1956
+ }
1957
+
1914
1958
function makeMap ( str , expectsLowerCase ) {
1915
1959
var map = Object . create ( null ) ;
1916
1960
var list = str . split ( ',' ) ;
@@ -2297,7 +2341,7 @@ function createStubFromComponent(
2297
2341
2298
2342
// DEPRECATED: converts string stub to template stub.
2299
2343
function createStubFromString ( templateString , name ) {
2300
- warn ( 'String stubs are deprecated and will be removed in future versions ') ;
2344
+ warnDeprecated ( 'Using a string for stubs ') ;
2301
2345
2302
2346
if ( templateContainsComponent ( templateString , name ) ) {
2303
2347
throwError ( 'options.stub cannot contain a circular reference' ) ;
@@ -2644,6 +2688,10 @@ function mergeOptions(
2644
2688
) {
2645
2689
var mocks = ( getOption ( options . mocks , config . mocks ) ) ;
2646
2690
var methods = ( getOption ( options . methods , config . methods ) ) ;
2691
+ if ( methods && Object . keys ( methods ) . length ) {
2692
+ warnDeprecated ( 'overwriting methods via the `methods` property' ) ;
2693
+ }
2694
+
2647
2695
var provide = ( getOption ( options . provide , config . provide ) ) ;
2648
2696
var stubs = ( getStubs ( options . stubs , config . stubs ) ) ;
2649
2697
// $FlowIgnore
@@ -2702,6 +2750,20 @@ function vueExtendUnsupportedOption(option) {
2702
2750
var UNSUPPORTED_VERSION_OPTIONS = [ 'mocks' , 'stubs' , 'localVue' ] ;
2703
2751
2704
2752
function validateOptions ( options , component ) {
2753
+ if (
2754
+ options . attachTo &&
2755
+ ! isHTMLElement ( options . attachTo ) &&
2756
+ ! isDomSelector ( options . attachTo )
2757
+ ) {
2758
+ throwError (
2759
+ "options.attachTo should be a valid HTMLElement or CSS selector string"
2760
+ ) ;
2761
+ }
2762
+ if ( 'attachToDocument' in options ) {
2763
+ warn (
2764
+ "options.attachToDocument is deprecated in favor of options.attachTo and will be removed in a future release"
2765
+ ) ;
2766
+ }
2705
2767
if ( options . parentComponent && ! isPlainObject ( options . parentComponent ) ) {
2706
2768
throwError (
2707
2769
"options.parentComponent should be a valid Vue component options object"
0 commit comments