Adding hotfixes for packages
	
		
			
	
		
	
	
		
	
		
			All checks were successful
		
		
	
	
		
			
				
	
				continuous-integration/drone/push Build is passing
				
			
		
		
	
	
				
					
				
			
		
			All checks were successful
		
		
	
	continuous-integration/drone/push Build is passing
				
			This commit is contained in:
		
							
								
								
									
										13
									
								
								jsx-html/node/utils/htmlEncode.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								jsx-html/node/utils/htmlEncode.ts
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,13 @@
 | 
			
		||||
export function doubleQuoteEncode(text: string): string {
 | 
			
		||||
    return text
 | 
			
		||||
        .replace(/"/g, '"')
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export function htmlEncode(text: string): string {
 | 
			
		||||
    return doubleQuoteEncode(text
 | 
			
		||||
        .replace(/&/g, '&')
 | 
			
		||||
        .replace(/\//g, '/')
 | 
			
		||||
        .replace(/</g, '<')
 | 
			
		||||
        .replace(/>/g, '>')
 | 
			
		||||
        .replace(/'/g, '''));
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										31
									
								
								jsx-html/node/utils/normalizeChildren.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								jsx-html/node/utils/normalizeChildren.ts
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,31 @@
 | 
			
		||||
import type { NullableChildType, ChildNodeType } from '../../types.ts';
 | 
			
		||||
import { TextNode } from '../TextNode.ts';
 | 
			
		||||
import { NODE_TYPE } from '../../constants.ts';
 | 
			
		||||
 | 
			
		||||
export function normalizeChildren(
 | 
			
		||||
    children: NullableChildType[],
 | 
			
		||||
): ChildNodeType[] {
 | 
			
		||||
    const result: any[] = [];
 | 
			
		||||
 | 
			
		||||
    for (const child of children) {
 | 
			
		||||
        if (child && typeof child !== 'boolean') {
 | 
			
		||||
            if (typeof child === 'string' || typeof child === 'number') {
 | 
			
		||||
                result.push(new TextNode(`${child}`));
 | 
			
		||||
            } else if (Array.isArray(child)) {
 | 
			
		||||
                normalizeChildren(child).forEach((normalized) =>
 | 
			
		||||
                    result.push(normalized),
 | 
			
		||||
                );
 | 
			
		||||
            } else if (
 | 
			
		||||
                child.type === NODE_TYPE.ELEMENT ||
 | 
			
		||||
                child.type === NODE_TYPE.TEXT ||
 | 
			
		||||
                child.type === NODE_TYPE.COMPONENT
 | 
			
		||||
            ) {
 | 
			
		||||
                result.push(child);
 | 
			
		||||
            } else {
 | 
			
		||||
                throw new TypeError(`Unrecognized node type: ${typeof child}`);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return result;
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user