Sha256: 5231775748a44fc2b753a5f8f1897918f155baab4ab1ba6ba3bf0d84ac4e4075

Contents?: true

Size: 1.11 KB

Versions: 12

Compression:

Stored size: 1.11 KB

Contents

# 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

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
isomorfeus-preact-23.9.0.rc12 lib/browser/history.rb
isomorfeus-preact-23.9.0.rc11 lib/browser/history.rb
isomorfeus-preact-23.9.0.rc10 lib/browser/history.rb
isomorfeus-preact-23.9.0.rc9 lib/browser/history.rb
isomorfeus-preact-23.9.0.rc8 lib/browser/history.rb
isomorfeus-preact-23.9.0.rc7 lib/browser/history.rb
isomorfeus-preact-23.9.0.rc6 lib/browser/history.rb
isomorfeus-preact-23.9.0.rc5 lib/browser/history.rb
isomorfeus-preact-23.9.0.rc4 lib/browser/history.rb
isomorfeus-preact-23.9.0.rc3 lib/browser/history.rb
isomorfeus-preact-23.9.0.rc2 lib/browser/history.rb
isomorfeus-preact-23.9.0.rc1 lib/browser/history.rb