Sha256: a906fa4e6523c64d42af734ead5dde82f11e2b73051c46b9b4c5d4ecdd637b53

Contents?: true

Size: 1.89 KB

Versions: 4

Compression:

Stored size: 1.89 KB

Contents

# frozen_string_literal: true

module Phlex
	class HTML < SGML
		# A list of HTML attributes that have the potential to execute unsafe JavaScript.
		EVENT_ATTRIBUTES = %w[onabort onafterprint onbeforeprint onbeforeunload onblur oncanplay oncanplaythrough onchange onclick oncontextmenu oncopy oncuechange oncut ondblclick ondrag ondragend ondragenter ondragleave ondragover ondragstart ondrop ondurationchange onemptied onended onerror onfocus onhashchange oninput oninvalid onkeydown onkeypress onkeyup onload onloadeddata onloadedmetadata onloadstart onmessage onmousedown onmousemove onmouseout onmouseover onmouseup onmousewheel onoffline ononline onpagehide onpageshow onpaste onpause onplay onplaying onpopstate onprogress onratechange onreset onresize onscroll onsearch onseeked onseeking onselect onstalled onstorage onsubmit onsuspend ontimeupdate ontoggle onunload onvolumechange onwaiting onwheel].to_h { [_1, true] }.freeze

		UNBUFFERED_MUTEX = Mutex.new

		class << self
			# @api private
			def __unbuffered_class__
				UNBUFFERED_MUTEX.synchronize do
					if defined? @unbuffered_class
						@unbuffered_class
					else
						@unbuffered_class = Class.new(Unbuffered)
					end
				end
			end
		end

		extend Elements
		include Helpers, VoidElements, StandardElements

		# Output an HTML doctype.
		def doctype
			@_target << "<!DOCTYPE html>"
			nil
		end

		# @deprecated use {#plain} instead.
		def text(...)
			warn "DEPRECATED: The `text` method has been deprecated in favour of `plain`. Please use `plain` instead. The `text` method will be removed in a future version of Phlex. Called from: #{caller.first}"
			plain(...)
		end

		def svg(...)
			super do
				render Phlex::SVG.new do |svg|
					yield(svg)
				end
			end
		end

		# @api private
		def unbuffered
			self.class.__unbuffered_class__.new(self)
		end

		# This should be extended after all method definitions
		extend ElementClobberingGuard
	end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
phlex-1.5.3 lib/phlex/html.rb
phlex-1.5.2 lib/phlex/html.rb
phlex-1.5.1 lib/phlex/html.rb
phlex-1.5.0 lib/phlex/html.rb