feat(sfc): ::v-global() pseudo selector support
This commit is contained in:
		
							parent
							
								
									8ea2101553
								
							
						
					
					
						commit
						31ca7858bb
					
				@ -29,18 +29,34 @@ export default postcss.plugin('add-id', (options: any) => (root: Root) => {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        // find the last child node to insert attribute selector
 | 
					        // find the last child node to insert attribute selector
 | 
				
			||||||
        selector.each((n: any) => {
 | 
					        selector.each((n: any) => {
 | 
				
			||||||
          if (n.type === 'pseudo' && n.value === '::v-deep') {
 | 
					          if (n.type === 'pseudo') {
 | 
				
			||||||
 | 
					            // deep: inject [id] attribute at the node before the ::v-deep
 | 
				
			||||||
 | 
					            // combinator.
 | 
				
			||||||
 | 
					            // .foo ::v-deep .bar -> .foo[xxxxxxx] .bar
 | 
				
			||||||
 | 
					            if (n.value === '::v-deep') {
 | 
				
			||||||
              n.value = n.spaces.before = n.spaces.after = ''
 | 
					              n.value = n.spaces.before = n.spaces.after = ''
 | 
				
			||||||
              return false
 | 
					              return false
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          if (n.type === 'pseudo' && n.value === '::v-slotted') {
 | 
					            // slot: use selector inside `::v-slotted` and inject [id + '-s']
 | 
				
			||||||
            rewriteSelector(n.nodes[0], 0, true)
 | 
					            // instead.
 | 
				
			||||||
 | 
					            // ::v-slotted(.foo) -> .foo[xxxxxxx-s]
 | 
				
			||||||
 | 
					            if (n.value === '::v-slotted') {
 | 
				
			||||||
 | 
					              rewriteSelector(n.nodes[0], 0, true /* slotted */)
 | 
				
			||||||
              selectors.insertAfter(selector, n.nodes[0])
 | 
					              selectors.insertAfter(selector, n.nodes[0])
 | 
				
			||||||
              selectors.removeChild(selector)
 | 
					              selectors.removeChild(selector)
 | 
				
			||||||
              return false
 | 
					              return false
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            // global: replace with inner selector and do not inject [id].
 | 
				
			||||||
 | 
					            // ::v-global(.foo) -> .foo
 | 
				
			||||||
 | 
					            if (n.value === '::v-global') {
 | 
				
			||||||
 | 
					              selectors.insertAfter(selector, n.nodes[0])
 | 
				
			||||||
 | 
					              selectors.removeChild(selector)
 | 
				
			||||||
 | 
					              return false
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          if (n.type !== 'pseudo' && n.type !== 'combinator') {
 | 
					          if (n.type !== 'pseudo' && n.type !== 'combinator') {
 | 
				
			||||||
            node = n
 | 
					            node = n
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user