# backtick_javascript: true module Browser class History if RUBY_ENGINE == 'opal' include DelegateNative def size length end def push_state(state, title = '', url = `null`) `#@native.pushState(Object.fromEntries(#{state}), #{title}, #{url})` end def replace_state(state, title = '', url = `null`) `#@native.replaceState(Object.fromEntries(#{state}), #{title}, #{url})` end def scroll_restoration `#@native.scrollRestoration` end def scroll_restoration=(s) `#@native.scrollRestoration = #{s}` end def state `(#@native.state) ? Opal.hash(#@native.state) : nil` end else def back; end def forward; end def go(_); end def length 0 end alias :size :length def push_state(state, title = '', url = nil); end def replace_state(state, title = '', url = nil); end def scroll_restoration; end def scroll_restoration=(s); end def state nil end end end end