Sha256: 08f617b90ebf7830205a2a0b5ff158670a45ead7e2dc4af340bc8b309ecd1ab5

Contents?: true

Size: 1.12 KB

Versions: 13

Compression:

Stored size: 1.12 KB

Contents

module Browser
  class History
    if RUBY_ENGINE == 'opal'
      include Native::Wrapper

      alias_native :back
      alias_native :forward
      alias_native :go

      native_reader :length
      alias :size :length

      def push_state(state, title = '', url = `null`)
        `#@native.pushState(#{state.to_n}, #{title}, #{url})`
      end

      def replace_state(state, title = '', url = `null`)
        `#@native.replaceState(#{state.to_n}, #{title}, #{url})`
      end

      def scroll_restoration
        `#@native.scrollRestoration`
      end

      def scroll_restoration=(s)
        `#@native.scrollRestoration = #{s}`
      end

      def state
        `Opal.hash(#@native.state)`
      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
        {}
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
isomorfeus-preact-23.7.0.rc5 lib/browser/history.rb
isomorfeus-preact-23.7.0.rc4 lib/browser/history.rb
isomorfeus-preact-23.7.0.rc3 lib/browser/history.rb
isomorfeus-preact-23.7.0.rc2 lib/browser/history.rb
isomorfeus-preact-23.7.0.rc1 lib/browser/history.rb
isomorfeus-preact-23.6.0.rc5 lib/browser/history.rb
isomorfeus-preact-23.6.0.rc4 lib/browser/history.rb
isomorfeus-preact-23.6.0.rc3 lib/browser/history.rb
isomorfeus-preact-23.6.0.rc2 lib/browser/history.rb
isomorfeus-preact-23.6.0.rc1 lib/browser/history.rb
isomorfeus-preact-23.1.0.rc2 lib/browser/history.rb
isomorfeus-preact-23.1.0.rc1 lib/browser/history.rb
isomorfeus-preact-22.11.0.rc1 lib/browser/history.rb