lib/html2wt/separators.js
function(state, nodeA, sepHandlerA, nodeB, sepHandlerB) {
	let sepType, nlConstraints, aCons, bCons;

	if (nodeA.nextSibling === nodeB) {
		// sibling separator
		sepType = "sibling";
		aCons = sepHandlerA.after(nodeA, nodeB, state);
		bCons = sepHandlerB.before(nodeB, nodeA, state);
		nlConstraints = getSepNlConstraints(state, nodeA, aCons, nodeB, bCons);
	} else if (nodeB.parentNode === nodeA) {
		// parent-child separator, nodeA parent of nodeB
		sepType = "parent-child";
		aCons = sepHandlerA.firstChild(nodeA, nodeB, state);
		bCons = sepHandlerB.before(nodeB, nodeA, state);
		nlConstraints = getSepNlConstraints(state, nodeA, aCons, nodeB, bCons);
	} else if (nodeA.parentNode === nodeB) {
		// parent-child separator, nodeB parent of nodeA
		sepType = "child-parent";
		aCons = sepHandlerA.after(nodeA, nodeB, state);
		bCons = sepHandlerB.lastChild(nodeB, nodeA, state);
		nlConstraints = getSepNlConstraints(state, nodeA, aCons, nodeB, bCons);
	} else {
		// sibling separator
		sepType = "sibling";
		aCons = sepHandlerA.after(nodeA, nodeB, state);
		bCons = sepHandlerB.before(nodeB, nodeA, state);
		nlConstraints = getSepNlConstraints(state, nodeA, aCons, nodeB, bCons);
	}

	if (nodeA.nodeName === undefined) {
		console.trace();
	}

	if (state.sep.constraints) {
		// Merge the constraints
		state.sep.constraints = mergeConstraints(
			state.env,
			state.sep.constraints,
			nlConstraints
		);
	} else {
		state.sep.constraints = nlConstraints;
	}

	state.env.log('debug/wts/sep', function() {
		return 'constraint' +
			' | ' + sepType +
			' | <' + nodeA.nodeName + ',' + nodeB.nodeName + '>' +
			' | ' + JSON.stringify(state.sep.constraints) +
			' | ' + debugOut(nodeA) +
			' | ' + debugOut(nodeB);
	});

	state.sep.constraints.constraintInfo = {
		onSOL: state.onSOL,
		// force SOL state when separator is built/emitted
		forceSOL: sepHandlerB.forceSOL,
		sepType: sepType,
		nodeA: nodeA,
		nodeB: nodeB,
	};
}
function(state, nodeA, sepHandlerA, nodeB, sepHandlerB) {
	let sepType, nlConstraints, aCons, bCons;

	if (nodeA.nextSibling === nodeB) {
		// sibling separator
		sepType = "sibling";
		aCons = sepHandlerA.after(nodeA, nodeB, state);
		bCons = sepHandlerB.before(nodeB, nodeA, state);
		nlConstraints = getSepNlConstraints(state, nodeA, aCons, nodeB, bCons);
	} else if (nodeB.parentNode === nodeA) {
		// parent-child separator, nodeA parent of nodeB
		sepType = "parent-child";
		aCons = sepHandlerA.firstChild(nodeA, nodeB, state);
		bCons = sepHandlerB.before(nodeB, nodeA, state);
		nlConstraints = getSepNlConstraints(state, nodeA, aCons, nodeB, bCons);
	} else if (nodeA.parentNode === nodeB) {
		// parent-child separator, nodeB parent of nodeA
		sepType = "child-parent";
		aCons = sepHandlerA.after(nodeA, nodeB, state);
		bCons = sepHandlerB.lastChild(nodeB, nodeA, state);
		nlConstraints = getSepNlConstraints(state, nodeA, aCons, nodeB, bCons);
	} else {
		// sibling separator
		sepType = "sibling";
		aCons = sepHandlerA.after(nodeA, nodeB, state);
		bCons = sepHandlerB.before(nodeB, nodeA, state);
		nlConstraints = getSepNlConstraints(state, nodeA, aCons, nodeB, bCons);
	}

	if (nodeA.nodeName === undefined) {
		console.trace();
	}

	if (state.sep.constraints) {
		// Merge the constraints
		state.sep.constraints = mergeConstraints(
			state.env,
			state.sep.constraints,
			nlConstraints
		);
	} else {
		state.sep.constraints = nlConstraints;
	}

	state.env.log('debug/wts/sep', function() {
		return 'constraint' +
			' | ' + sepType +
			' | <' + nodeA.nodeName + ',' + nodeB.nodeName + '>' +
			' | ' + JSON.stringify(state.sep.constraints) +
			' | ' + debugOut(nodeA) +
			' | ' + debugOut(nodeB);
	});

	state.sep.constraints.constraintInfo = {
		onSOL: state.onSOL,
		// force SOL state when separator is built/emitted
		forceSOL: sepHandlerB.forceSOL,
		sepType: sepType,
		nodeA: nodeA,
		nodeB: nodeB,
	};
}
function ( state , nodeA , sepHandlerA , nodeB , sepHandlerB ) { let sepType , nlConstraints , aCons , bCons ; if ( nodeA . nextSibling === nodeB ) { // sibling separator sepType = "sibling" ; aCons = sepHandlerA . after ( nodeA , nodeB , state ) ; bCons = sepHandlerB . before ( nodeB , nodeA , state ) ; nlConstraints = getSepNlConstraints ( state , nodeA , aCons , nodeB , bCons ) ; } else if ( nodeB . parentNode === nodeA ) { // parent-child separator, nodeA parent of nodeB sepType = "parent-child" ; aCons = sepHandlerA . firstChild ( nodeA , nodeB , state ) ; bCons = sepHandlerB . before ( nodeB , nodeA , state ) ; nlConstraints = getSepNlConstraints ( state , nodeA , aCons , nodeB , bCons ) ; } else if ( nodeA . parentNode === nodeB ) { // parent-child separator, nodeB parent of nodeA sepType = "child-parent" ; aCons = sepHandlerA . after ( nodeA , nodeB , state ) ; bCons = sepHandlerB . lastChild ( nodeB , nodeA , state ) ; nlConstraints = getSepNlConstraints ( state , nodeA , aCons , nodeB , bCons ) ; } else { // sibling separator sepType = "sibling" ; aCons = sepHandlerA . after ( nodeA , nodeB , state ) ; bCons = sepHandlerB . before ( nodeB , nodeA , state ) ; nlConstraints = getSepNlConstraints ( state , nodeA , aCons , nodeB , bCons ) ; } if ( nodeA . nodeName === undefined ) { console . trace ( ) ; } if ( state . sep . constraints ) { // Merge the constraints state . sep . constraints = mergeConstraints ( state . env , state . sep . constraints , nlConstraints ) ; } else { state . sep . constraints = nlConstraints ; } state . env . log ( 'debug/wts/sep' , function ( ) { return 'constraint' + ' | ' + sepType + ' | <' + nodeA . nodeName + ',' + nodeB . nodeName + '>' + ' | ' + JSON . stringify ( state . sep . constraints ) + ' | ' + debugOut ( nodeA ) + ' | ' + debugOut ( nodeB ) ; } ) ; state . sep . constraints . constraintInfo = { onSOL : state . onSOL , // force SOL state when separator is built/emitted forceSOL : sepHandlerB . forceSOL , sepType : sepType , nodeA : nodeA , nodeB : nodeB , } ; }
Figure out separator constraints and merge them with existing constraints
in state so that they can be emitted when the next content emits source.
@param {Node} nodeA
@param {DOMHandler} sepHandlerA
@param {Node} nodeB
@param {DOMHandler} sepHandlerB
Figure out separator constraints and merge them with existing constraints in state so that they can be emitted when the next content emits source .