Sha256: 3ebcadc11d74e25d881083c82d90875051aedfcb92d3318d61b0b747fedda583

Contents?: true

Size: 1.12 KB

Versions: 11

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
        ::Hash.new(`#@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

11 entries across 11 versions & 1 rubygems

Version Path
isomorfeus-preact-22.10.0.rc2 lib/browser/history.rb
isomorfeus-preact-22.10.0.rc1 lib/browser/history.rb
isomorfeus-preact-22.9.0.rc9 lib/browser/history.rb
isomorfeus-preact-22.9.0.rc8 lib/browser/history.rb
isomorfeus-preact-22.9.0.rc7 lib/browser/history.rb
isomorfeus-preact-22.9.0.rc6 lib/browser/history.rb
isomorfeus-preact-22.9.0.rc5 lib/browser/history.rb
isomorfeus-preact-22.9.0.rc4 lib/browser/history.rb
isomorfeus-preact-22.9.0.rc3 lib/browser/history.rb
isomorfeus-preact-22.9.0.rc2 lib/browser/history.rb
isomorfeus-preact-22.9.0.rc1 lib/browser/history.rb