Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(weex): implement "weex.supports" api to support feature detection #6053

Merged
merged 2 commits into from
Jul 10, 2017

Conversation

Hanks10100
Copy link
Contributor

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update
  • Refactor
  • Build-related changes
  • Other, please describe:

Does this PR introduce a breaking change?

  • Yes
  • No

Other information:

weex.supports

weex.supports is used to detect whether a feature is supported in the current environment.

API

weex.supports(condition: String): Boolean | Null

Parameter

  • a formatted string: @{type}/{name}.

The type must be "component" or "module", the name can be tag name, module name or the method name in a specific module.

Return Value

  • if supported, returns true.
  • if unsupported, returns false.
  • if unclear, returns null.

Examples

// Detects whether the specific component is supported
weex.supports('@component/slider') // true
weex.supports('@component/my-tab') // false

// Detects whether the specific module is supported
weex.supports('@module/stream')  // true
weex.supports('@module/abcdef')  // false

// Detects whether the method in specific module is supported
weex.supports('@module/dom.getComponentRect') // true
weex.supports('@module/navigator.jumpToPage') // false

// invalid input
weex.supports('div') // null
weex.supports('module/*') // null
weex.supports('@stream/fetch') // null
weex.supports('getComponentRect') // null

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants