chore: remove unused util function
This commit is contained in:
		
							parent
							
								
									f7a7e8d71d
								
							
						
					
					
						commit
						516501e20e
					
				@ -1,9 +1,5 @@
 | 
				
			|||||||
import { Position, NodeTypes } from '../src/ast'
 | 
					import { Position } from '../src/ast'
 | 
				
			||||||
import {
 | 
					import { getInnerRange, advancePositionWithClone } from '../src/utils'
 | 
				
			||||||
  getInnerRange,
 | 
					 | 
				
			||||||
  advancePositionWithClone,
 | 
					 | 
				
			||||||
  isEmptyExpression
 | 
					 | 
				
			||||||
} from '../src/utils'
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
function p(line: number, column: number, offset: number): Position {
 | 
					function p(line: number, column: number, offset: number): Position {
 | 
				
			||||||
  return { column, line, offset }
 | 
					  return { column, line, offset }
 | 
				
			||||||
@ -71,41 +67,3 @@ describe('getInnerRange', () => {
 | 
				
			|||||||
    expect(loc2.end.offset).toBe(7)
 | 
					    expect(loc2.end.offset).toBe(7)
 | 
				
			||||||
  })
 | 
					  })
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
 | 
					 | 
				
			||||||
describe('isEmptyExpression', () => {
 | 
					 | 
				
			||||||
  test('empty', () => {
 | 
					 | 
				
			||||||
    expect(
 | 
					 | 
				
			||||||
      isEmptyExpression({
 | 
					 | 
				
			||||||
        content: '',
 | 
					 | 
				
			||||||
        type: NodeTypes.SIMPLE_EXPRESSION,
 | 
					 | 
				
			||||||
        isStatic: true,
 | 
					 | 
				
			||||||
        isConstant: true,
 | 
					 | 
				
			||||||
        loc: null as any
 | 
					 | 
				
			||||||
      })
 | 
					 | 
				
			||||||
    ).toBe(true)
 | 
					 | 
				
			||||||
  })
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  test('spaces', () => {
 | 
					 | 
				
			||||||
    expect(
 | 
					 | 
				
			||||||
      isEmptyExpression({
 | 
					 | 
				
			||||||
        content: '  \t  ',
 | 
					 | 
				
			||||||
        type: NodeTypes.SIMPLE_EXPRESSION,
 | 
					 | 
				
			||||||
        isStatic: true,
 | 
					 | 
				
			||||||
        isConstant: true,
 | 
					 | 
				
			||||||
        loc: null as any
 | 
					 | 
				
			||||||
      })
 | 
					 | 
				
			||||||
    ).toBe(true)
 | 
					 | 
				
			||||||
  })
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  test('identifier', () => {
 | 
					 | 
				
			||||||
    expect(
 | 
					 | 
				
			||||||
      isEmptyExpression({
 | 
					 | 
				
			||||||
        content: 'foo',
 | 
					 | 
				
			||||||
        type: NodeTypes.SIMPLE_EXPRESSION,
 | 
					 | 
				
			||||||
        isStatic: true,
 | 
					 | 
				
			||||||
        isConstant: true,
 | 
					 | 
				
			||||||
        loc: null as any
 | 
					 | 
				
			||||||
      })
 | 
					 | 
				
			||||||
    ).toBe(false)
 | 
					 | 
				
			||||||
  })
 | 
					 | 
				
			||||||
})
 | 
					 | 
				
			||||||
 | 
				
			|||||||
@ -164,7 +164,7 @@ export function findProp(
 | 
				
			|||||||
    const p = node.props[i]
 | 
					    const p = node.props[i]
 | 
				
			||||||
    if (p.type === NodeTypes.ATTRIBUTE) {
 | 
					    if (p.type === NodeTypes.ATTRIBUTE) {
 | 
				
			||||||
      if (dynamicOnly) continue
 | 
					      if (dynamicOnly) continue
 | 
				
			||||||
      if (p.name === name && p.value && !p.value.isEmpty) {
 | 
					      if (p.name === name && p.value) {
 | 
				
			||||||
        return p
 | 
					        return p
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    } else if (
 | 
					    } else if (
 | 
				
			||||||
@ -248,10 +248,6 @@ export function toValidAssetId(
 | 
				
			|||||||
  return `_${type}_${name.replace(/[^\w]/g, '_')}`
 | 
					  return `_${type}_${name.replace(/[^\w]/g, '_')}`
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export function isEmptyExpression(node: ExpressionNode) {
 | 
					 | 
				
			||||||
  return node.type === NodeTypes.SIMPLE_EXPRESSION && !node.content.trim()
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// Check if a node contains expressions that reference current context scope ids
 | 
					// Check if a node contains expressions that reference current context scope ids
 | 
				
			||||||
export function hasScopeRef(
 | 
					export function hasScopeRef(
 | 
				
			||||||
  node: TemplateChildNode | IfBranchNode | ExpressionNode | undefined,
 | 
					  node: TemplateChildNode | IfBranchNode | ExpressionNode | undefined,
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user