Skip to content

Commit

Permalink
Optimize scopeSelector (#20819)
Browse files Browse the repository at this point in the history
  • Loading branch information
jridgewell authored Feb 13, 2019
1 parent 0298883 commit f92f627
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -528,15 +528,12 @@ function isScopeSelectorSupported(parent) {
* scopeSelector('article >', 'div, ul'); // article > div, article > ul
* ```
*
* @param {string} ancestorSelector
* @param {string} descendantSelector
* @param {string} distribute
* @param {string} selector
* @return {string}
*/
function scopeSelector(ancestorSelector, descendantSelector) {
return descendantSelector
.split(',')
.map(subSelector => `${ancestorSelector} ${subSelector}`)
.join(',');
function scopeSelector(distribute, selector) {
return selector.replace(/^|,/g, `$&${distribute} `);
}

export const scopeSelectorForTesting = scopeSelector;
Expand Down

0 comments on commit f92f627

Please sign in to comment.