@@ -215,13 +215,16 @@ var zest = (function () {
215215 *
216216 * accepts text/html/css-selector, Node, NodeList, function, iterable
217217 */
218- const argsToElements = function ( args , el , index ) {
218+ const argsToElements = function ( args , acceptSelector , el , index ) {
219219 const elements = [ ] ;
220220 args = Array . from ( args ) ; // shallow copy so not affecting original
221221 while ( args . length ) {
222222 const arg = args . shift ( ) ;
223223 if ( typeof arg === 'string' ) {
224- let elementsAppend = isCssSelector ( arg ) ;
224+ let elementsAppend = false ;
225+ if ( acceptSelector ) {
226+ elementsAppend = isCssSelector ( arg ) ;
227+ }
225228 if ( elementsAppend === false ) {
226229 elementsAppend = createElements ( arg ) ;
227230 }
@@ -335,6 +338,7 @@ var zest = (function () {
335338 }
336339 */
337340
341+ // return found elements or false
338342 const isCssSelector = function ( val )
339343 {
340344 if ( val . includes ( '<' ) ) {
@@ -807,7 +811,7 @@ var zest = (function () {
807811 } else if ( typeof mixed === 'function' ) {
808812 isMatch = mixed . call ( el , el , i ) ;
809813 } else {
810- isMatch = argsToElements ( [ mixed ] ) . includes ( el ) ;
814+ isMatch = argsToElements ( [ mixed ] , true ) . includes ( el ) ;
811815 }
812816 if ( notFilter ) {
813817 isMatch = ! isMatch ;
@@ -844,6 +848,7 @@ var zest = (function () {
844848 }
845849 return false
846850 }
851+ // Node, NodeList, function, iterable
847852 const elements = argsToElements ( [ mixed ] ) ;
848853 for ( let el of this ) {
849854 for ( let i = 0 , len = elements . length ; i < len ; i ++ ) {
@@ -1061,7 +1066,7 @@ var zest = (function () {
10611066 if ( typeof mixed === 'string' ) {
10621067 return this . alter ( ( el ) => querySelectorAll ( mixed , el ) )
10631068 }
1064- const elements = argsToElements ( [ mixed ] ) ;
1069+ const elements = argsToElements ( [ mixed ] , true ) ;
10651070 return this . alter ( ( el ) => {
10661071 const collected = [ ] ;
10671072 for ( const el2 of elements ) {
@@ -1491,7 +1496,7 @@ var zest = (function () {
14911496
14921497 after ( ...args ) {
14931498 return this . each ( ( el , i ) => {
1494- const elementsNew = argsToElements ( args , el , i ) ;
1499+ const elementsNew = argsToElements ( args , false , el , i ) ;
14951500 elementsNew . reverse ( ) ;
14961501 for ( const elNew of elementsNew ) {
14971502 el . after ( elNew ) ;
@@ -1500,15 +1505,15 @@ var zest = (function () {
15001505 }
15011506 append ( ...args ) {
15021507 return this . each ( ( el , i ) => {
1503- const elementsNew = argsToElements ( args , el , i ) ;
1508+ const elementsNew = argsToElements ( args , false , el , i ) ;
15041509 for ( const elNew of elementsNew ) {
15051510 el . append ( elNew ) ;
15061511 }
15071512 } )
15081513 }
15091514 before ( ...args ) {
15101515 return this . each ( ( el , i ) => {
1511- const elementsNew = argsToElements ( args , el , i ) ;
1516+ const elementsNew = argsToElements ( args , false , el , i ) ;
15121517 for ( const elNew of elementsNew ) {
15131518 el . before ( elNew ) ;
15141519 }
@@ -1565,7 +1570,7 @@ var zest = (function () {
15651570 }
15661571 prepend ( ...args ) {
15671572 return this . each ( ( el , i ) => {
1568- const elementsNew = argsToElements ( args , el , i ) ;
1573+ const elementsNew = argsToElements ( args , false , el , i ) ;
15691574 elementsNew . reverse ( ) ;
15701575 for ( const elNew of elementsNew ) {
15711576 el . prepend ( elNew ) ;
@@ -1584,7 +1589,7 @@ var zest = (function () {
15841589 }
15851590 replaceWith ( ...args ) {
15861591 return this . each ( ( el , i ) => {
1587- const elementsNew = argsToElements ( args , el , i ) ;
1592+ const elementsNew = argsToElements ( args , false , el , i ) ;
15881593 el . replaceWith ( ...elementsNew ) ;
15891594 } )
15901595 }
@@ -1637,8 +1642,8 @@ var zest = (function () {
16371642 if ( typeof mixed === 'function' ) {
16381643 mixed = mixed . call ( el , el , i ) ;
16391644 }
1640- // mixed can be a string, MicroDom instance, or a DOM element
1641- const elements = argsToElements ( [ mixed ] ) ;
1645+ // mixed can be a string (but not css selector) , MicroDom instance, or a DOM element
1646+ const elements = argsToElements ( [ mixed ] , false ) ;
16421647 const wrapperElement = elements [ 0 ] . cloneNode ( true ) ;
16431648 const wrapperElementDeepest = findDeepest ( wrapperElement ) ;
16441649 el . replaceWith ( wrapperElement ) ;
@@ -1650,8 +1655,8 @@ var zest = (function () {
16501655 if ( typeof mixed === 'function' ) {
16511656 mixed = mixed . call ( el , el , i ) ;
16521657 }
1653- // mixed can be a string, MicroDom instance, or a DOM element
1654- const elements = argsToElements ( [ mixed ] ) ;
1658+ // mixed can be a string (but not css selector) , MicroDom instance, or a DOM element
1659+ const elements = argsToElements ( [ mixed ] , false ) ;
16551660 const wrapperElement = elements [ 0 ] . cloneNode ( true ) ;
16561661 const wrapperElementDeepest = findDeepest ( wrapperElement ) ;
16571662 // Move the element's children (incl text/comment nodes) into the wrapper
0 commit comments