Sha256: 6a12c3bd01f6f8106cac256093ba393895999fdf9f3582e3a08497d3eaf05886
Contents?: true
Size: 1.01 KB
Versions: 24
Compression:
Stored size: 1.01 KB
Contents
module React module Test class Session DSL_METHODS = %i[mount instance update_params html].freeze def mount(component_klass, params = {}) @element = React.create_element(component_klass, params) instance end def instance unless @instance @container = `document.createElement('div')` @instance = React.render(@element, @container) end @instance end def update_params(params, &block) cloned_element = React::Element.new(`React.cloneElement(#{@element.to_n}, #{params.to_n})`) React.render(cloned_element, @container, &block) nil end def html html = `#@container.innerHTML` %x{ var REGEX_REMOVE_ROOT_IDS = /\s?data-reactroot="[^"]*"/g; var REGEX_REMOVE_IDS = /\s?data-reactid="[^"]+"/g; html = html.replace(REGEX_REMOVE_ROOT_IDS, ''); html = html.replace(REGEX_REMOVE_IDS, ''); } return html end end end end
Version data entries
24 entries across 24 versions & 2 rubygems