All files / src/lifecycles trinsicLifecycle.ts

88.89% Statements 8/9
16.67% Branches 1/6
100% Functions 2/2
88.89% Lines 8/9

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30                1x 1x 1x   1x 1x 1x   1x             1x            
import { style } from 'support';
import { LifecycleHub, Lifecycle } from 'lifecycles/lifecycleHub';
 
/**
 * Lifecycle with the responsibility to adjust the trinsic behavior of the content element.
 * @param lifecycleHub
 * @returns
 */
export const createTrinsicLifecycle = (lifecycleHub: LifecycleHub): Lifecycle => {
  const { _structureSetup } = lifecycleHub;
  const { _content } = _structureSetup._targetObj;
 
  return (updateHints) => {
    const { _heightIntrinsic } = updateHints;
    const [heightIntrinsic, heightIntrinsicChanged] = _heightIntrinsic;
 
    Iif (heightIntrinsicChanged) {
      style(_content, {
        height: heightIntrinsic ? '' : '100%',
        display: heightIntrinsic ? '' : 'inline',
      });
    }
 
    return {
      _sizeChanged: heightIntrinsicChanged,
      _contentMutation: heightIntrinsicChanged,
    };
  };
};