<commit_before>import { each } from '../../utils/generic'


export default function initialize () {

	const activeContainerIds = []
	const activeSequenceIds = []

	each(this.store.elements, element => {
		if (activeContainerIds.indexOf(element.containerId) === -1) {
			activeContainerIds.push(element.containerId)
		}
		if (activeSequenceIds.indexOf(element.sequence.id) === -1) {
			activeSequenceIds.push(element.sequence.id)
		}

		let styles = [element.styles.inline]

		if (element.visible) {
			styles.push(element.styles.opacity.computed)
			styles.push(element.styles.transform.generated.final)
		} else {
			styles.push(element.styles.opacity.generated)
			styles.push(element.styles.transform.generated.initial)
		}

		element.node.setAttribute('style', styles.join(' '))
	})

	/**
	 * Remove unused sequences.
	 */
	each(this.store.sequences, sequence => {
		if (activeSequenceIds.indexOf(sequence.id) === -1) {
			delete this.store.sequences[sequence.id]
		}
	})

	each(this.store.containers, container => {

		/**
		 * Remove unused containers.
		 */
		if (activeContainerIds.indexOf(container.id) === -1) {
			container.node.removeEventListener('scroll', this.delegate)
			container.node.removeEventListener('resize', this.delegate)
			delete this.store.containers[container.id]

		/**
		 * Bind event listeners
		 */
		} else if (container.node === document.documentElement) {
			window.addEventListener('scroll', this.delegate)
			window.addEventListener('resize', this.delegate)
		} else {
			container.node.addEventListener('scroll', this.delegate)
			container.node.addEventListener('resize', this.delegate)
		}
	})

	/**
	 * Manually invoke delegate once to capture
	 * element and container dimensions, container
	 * scroll position, and trigger any valid reveals
	 */
	this.delegate()

	this.initTimeout = null
}
<commit_msg>check for element sequence before use during initialization<commit_after>import { each } from '../../utils/generic'


export default function initialize () {

	const activeContainerIds = []
	const activeSequenceIds = []

	each(this.store.elements, element => {
		if (activeContainerIds.indexOf(element.containerId) === -1) {
			activeContainerIds.push(element.containerId)
		}
		if (element.sequence && activeSequenceIds.indexOf(element.sequence.id) === -1) {
			activeSequenceIds.push(element.sequence.id)
		}

		let styles = [element.styles.inline]

		if (element.visible) {
			styles.push(element.styles.opacity.computed)
			styles.push(element.styles.transform.generated.final)
		} else {
			styles.push(element.styles.opacity.generated)
			styles.push(element.styles.transform.generated.initial)
		}

		element.node.setAttribute('style', styles.join(' '))
	})

	/**
	 * Remove unused sequences.
	 */
	each(this.store.sequences, sequence => {
		if (activeSequenceIds.indexOf(sequence.id) === -1) {
			delete this.store.sequences[sequence.id]
		}
	})

	each(this.store.containers, container => {

		/**
		 * Remove unused containers.
		 */
		if (activeContainerIds.indexOf(container.id) === -1) {
			container.node.removeEventListener('scroll', this.delegate)
			container.node.removeEventListener('resize', this.delegate)
			delete this.store.containers[container.id]

		/**
		 * Bind event listeners
		 */
		} else if (container.node === document.documentElement) {
			window.addEventListener('scroll', this.delegate)
			window.addEventListener('resize', this.delegate)
		} else {
			container.node.addEventListener('scroll', this.delegate)
			container.node.addEventListener('resize', this.delegate)
		}
	})

	/**
	 * Manually invoke delegate once to capture
	 * element and container dimensions, container
	 * scroll position, and trigger any valid reveals
	 */
	this.delegate()

	this.initTimeout = null
}

{'fraction_non_alphanumeric': 0.13955342902711323, 'fraction_numerical': 0.002126528442317916, 'mean_word_length': 4.051006711409396, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4995011', 'n_tokens_mistral': 1212, 'n_tokens_neox': 1069, 'n_words': 198}