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

Projects
None yet
2 participants
@Hanks10100
Collaborator

Hanks10100 commented Jul 7, 2017

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

@Hanks10100 Hanks10100 added the weex label Jul 7, 2017

@yyx990803 yyx990803 merged commit b1512d8 into vuejs:dev Jul 10, 2017

1 check passed

ci/circleci Your tests passed on CircleCI!
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment