Code Monkey home page Code Monkey logo

history.state's Issues

单元测试中的探测 Android 系统版本的部分应该改为探测 WebKit 版本

在 Android 平台下,浏览器对 HTML5 特性的实现与否实际上取决于其使用的 WebKit 版本,而非 Android 版本。由于 Android 各版本原生内置 WebKit 引擎的版本是固定的,由 Android 系统版本来推测其内置浏览器的行为是可行的。

但 Andriod 系统下的第三方浏览器(比如 QQ 浏览器等)有可能自带内核,其 WebKit 版本可能超越系统。在这种情况下,现有测试是通不过的。

新增构建机制

要实现以下需求:

  • 发布 UMD 包
  • 在发布版中滤除调试代码

_hasHistoryAPI

function _hasHistoryAPI() {
        return 'onpopstate' in window &&
            'replaceState' in history && typeof history.replaceState === 'function' &&
            'replaceState' in history && typeof history.replaceState === 'function'
    }

应该是检测pushState 和 'replaceState' 吧,代码里面2个'replaceState'

API 文档

API 文档

JavaScript 接口  

historyState.isSupported()  

判断当前环境是否支持通过 history.state 属性获取当前 state。

这是一个非常重要的方法,如果你的业务需要使用 history.state 特性,务必先使用此方法探测其是否可用。

参数

(无)

返回值

布尔值。

示例

// 在 iOS 5.x 或 Android 4.0~4.3 下运行:
historyState.isSupported()  // => false

historyState.polyfill()
historyState.isSupported()  // => true

[已弃用] historyState.polyfill()  

初始化方法。

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.