You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
1.0 KiB
JavaScript

import {ELEMENT_NODE} from './constants.js';
import {END, MIME, NEXT, PREV} from './symbols.js';
const $String = String;
export {$String as String};
export const getEnd = node => node.nodeType === ELEMENT_NODE ? node[END] : node;
export const ignoreCase = ({ownerDocument}) => ownerDocument[MIME].ignoreCase;
export const knownAdjacent = (prev, next) => {
prev[NEXT] = next;
next[PREV] = prev;
};
export const knownBoundaries = (prev, current, next) => {
knownAdjacent(prev, current);
knownAdjacent(getEnd(current), next);
};
export const knownSegment = (prev, start, end, next) => {
knownAdjacent(prev, start);
knownAdjacent(getEnd(end), next);
};
export const knownSiblings = (prev, current, next) => {
knownAdjacent(prev, current);
knownAdjacent(current, next);
};
export const localCase = ({localName, ownerDocument}) => {
return ownerDocument[MIME].ignoreCase ? localName.toUpperCase() : localName;
};
export const setAdjacent = (prev, next) => {
if (prev)
prev[NEXT] = next;
if (next)
next[PREV] = prev;
};