<commit_before>	'use strict'

	assert = require 'assert'
	utils = require 'utils'
	signal = require 'signal'
	log = require 'log'
	Renderer = require 'renderer'

	log = log.scope 'Styles'

	module.exports = (File, data) -> class Style
		{windowStyle, styles} = data

		@__name__ = 'Style'
		@__path__ = 'File.Style'

		@HTML_ATTR = "#{File.HTML_NS}:style"
		@HTML_DEEP_ATTR = "#{Style.HTML_ATTR}:"

		listenRecursive = (style, node, event, listener) ->
			assert.instanceOf style, Style
			assert.instanceOf node, File.Element

			node[event] listener, style

			if node.children
				for child in node.children
					listenRecursive style, child, event, listener

			null

		visibilityChangedListener = ->
			if @file.isRendered
				@updateVisibility()

		textChangedListener = ->
			if @file.isRendered
				@updateText()

		attrChangedListener = (e, node) ->
			if e.name is Style.HTML_ATTR
				@reloadItem()
				if @file.isRendered
					@render()

			if @file.isRendered
				return unless @attrs?.hasOwnProperty(e.name)
				value = node.attrs.get e.name
				if @file.funcs?.hasOwnProperty value
					log.warn "Dynamic listening on Renderer events is not supported"
					return
				@setAttr e.name, value

		reloadItemsRecursively = (style) ->
			style.reloadItem()

			for child in style.children
				reloadItemsRecursively child

			return

		anchorListener = ->
			url = @node.attrs.get 'href'
			unless url
				return

			@file.storage.global?.uri = url
<commit_msg>`Element.Emitter` replaced by `signal.Emitter` support added<commit_after>	'use strict'

	assert = require 'assert'
	utils = require 'utils'
	signal = require 'signal'
	log = require 'log'
	Renderer = require 'renderer'

	log = log.scope 'Styles'

	module.exports = (File, data) -> class Style
		{windowStyle, styles} = data

		@__name__ = 'Style'
		@__path__ = 'File.Style'

		@HTML_ATTR = "#{File.HTML_NS}:style"
		@HTML_DEEP_ATTR = "#{Style.HTML_ATTR}:"

		listenRecursive = (style, node, event, listener) ->
			assert.instanceOf style, Style
			assert.instanceOf node, File.Element

			node[event]? listener, style

			if node.children
				for child in node.children
					listenRecursive style, child, event, listener

			null

		visibilityChangedListener = ->
			if @file.isRendered
				@updateVisibility()

		textChangedListener = ->
			if @file.isRendered
				@updateText()

		attrChangedListener = (e) ->
			if e.name is Style.HTML_ATTR
				@reloadItem()
				if @file.isRendered
					@render()

			if @file.isRendered
				return unless @attrs?.hasOwnProperty(e.name)
				value = @node.attrs.get e.name
				if @file.funcs?.hasOwnProperty value
					log.warn "Dynamic listening on Renderer events is not supported"
					return
				@setAttr e.name, value

		reloadItemsRecursively = (style) ->
			style.reloadItem()

			for child in style.children
				reloadItemsRecursively child

			return

		anchorListener = ->
			url = @node.attrs.get 'href'
			unless url
				return

			@file.storage.global?.uri = url

{'fraction_non_alphanumeric': 0.11029165269862555, 'fraction_numerical': 0.0, 'mean_word_length': 3.244665718349929, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, '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': '2173514', 'n_tokens_mistral': 1158, 'n_tokens_neox': 946, 'n_words': 254}