npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

history.state

v2.0.0

Published

Polyfill `history.state` on iOS 5- and Android 4.3-.

Downloads

2

Readme

history.state

Polyfill history.state on iOS 5- and Android 4.3-.

简介

iOS 5+ 和 Android 4+ 已经比较稳定地实现了 HTML5 History API:

  • history.pushState() 方法
  • history.replaceState() 方法
  • popstate 事件

但直到 iOS 6+ 和 Android 4.4+ 才支持 history.state 属性。

这个属性还是很重要的。通过它,脚本在任何时候都可以获知当前处于哪个 state,而不是只能在 popstate 事件的回调中通过 event.state 来获知。

本项目将在那些支持 popstate 事件但不支持 history.state 属性的浏览器中模拟原生的 history.state 行为。

兼容性

作为一个 polyfill 脚本,本项目是透明的:

  • 在不需要打补丁的环境中,直接退出
  • 在需要打补丁的环境中,模拟原生行为
  • 在无法打补丁的环境中,向控制台报错后退出

本项目的初衷是面向移动浏览器的,将在以下移动平台的主流浏览器中发挥作用:

  • iOS 5.x
  • Android 4.0 ~ 4.3

(更早的移动浏览器对 HTML5 History API 的实现有缺陷,无法保证效果。)

安装

  1. 通过 Bower 安装:

    $ bower install history.state
  2. 在页面中加载本项目的脚本文件:

    <script src="bower_components/history.state/src/history.state.js"></script>

(注:从 2.0 版开始,polyfill 会自动执行,无需手动调用。)

API 文档

所有文档入口在 Wiki 页面,快去看吧!

单元测试

  1. 把本项目的代码 fork 并 clone 到本地。
  2. 在本项目的根目录运行 bower install,安装必要的依赖。
  3. 在浏览器中打开 test/test.html 即可运行单元测试。

如果想在移动设备上运行单元测试,可尝试以下任一方法:

  • 在本地建立 Web 服务,以便移动设备通过局域网访问上述单元测试页面。
  • 把本项目的所有文件(及必要的依赖)发布至公网,以便移动设备访问上述单元测试页面。

谁在用?

以下开源项目采用本项目作为基础组件:

因此,本项目运行在以下网站:


License

MIT License