You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by da...@apache.org on 2017/07/20 08:29:40 UTC
[10/50] incubator-weex git commit: * [html5] move tool function into
func.js
* [html5] move tool function into func.js
Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/5c1dc226
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/5c1dc226
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/5c1dc226
Branch: refs/heads/0.15-dev
Commit: 5c1dc2262a75382437edd8c76c07118de264d754
Parents: 7c42710
Author: erha19 <fa...@gmail.com>
Authored: Mon Jul 10 15:07:52 2017 +0800
Committer: erha19 <fa...@gmail.com>
Committed: Mon Jul 10 15:07:52 2017 +0800
----------------------------------------------------------------------
html5/render/vue/utils/index.js | 104 -----------------------------------
1 file changed, 104 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/5c1dc226/html5/render/vue/utils/index.js
----------------------------------------------------------------------
diff --git a/html5/render/vue/utils/index.js b/html5/render/vue/utils/index.js
index 032c472..7d5dfbd 100644
--- a/html5/render/vue/utils/index.js
+++ b/html5/render/vue/utils/index.js
@@ -22,107 +22,3 @@ export * from './component'
export * from './lazyload'
export * from './style'
export * from './type'
-
-/**
- * Create a cached version of a pure function.
- */
-export function cached (fn) {
- const cache = Object.create(null)
- return function cachedFn (str) {
- const hit = cache[str]
- return hit || (cache[str] = fn(str))
- }
-}
-
-/**
- * Camelize a hyphen-delmited string.
- */
-const camelizeRE = /-(\w)/g
-export const camelize = cached(str => {
- return str.replace(camelizeRE, (_, c) => c.toUpperCase())
-})
-
-export function camelizeKeys (obj) {
- const res = {}
- for (const key in obj) {
- res[camelize(key)] = obj[key]
- }
- return res
-}
-
-/**
- * Capitalize a string.
- */
-export const capitalize = cached(str => {
- return str.charAt(0).toUpperCase() + str.slice(1)
-})
-
-/**
- * Hyphenate a camelCase string.
- */
-const hyphenateRE = /([^-])([A-Z])/g
-export const hyphenate = cached(str => {
- return str
- .replace(hyphenateRE, '$1-$2')
- .replace(hyphenateRE, '$1-$2')
- .toLowerCase()
-})
-
-export function hyphenateKeys (obj) {
- const res = {}
- for (const key in obj) {
- res[hyphenate(key)] = obj[key]
- }
- return res
-}
-
-const vendorsReg = /webkit-|moz-|o-|ms-/
-export function hyphenateStyleKeys (obj) {
- const res = {}
- for (const key in obj) {
- const hk = hyphenate(key).replace(vendorsReg, function ($0) {
- return '-' + $0
- })
- res[hk] = obj[key]
- }
- return res
-}
-
-export function camelToKebab (name) {
- if (!name) { return '' }
- return name.replace(/([A-Z])/g, function (g, g1) {
- return `-${g1.toLowerCase()}`
- })
-}
-
-export function appendCss (css, cssId, replace) {
- let style = document.getElementById(cssId)
- if (style && replace) {
- style.parentNode.removeChild(style)
- style = null
- }
- if (!style) {
- style = document.createElement('style')
- style.type = 'text/css'
- cssId && (style.id = cssId)
- document.getElementsByTagName('head')[0].appendChild(style)
- }
- style.appendChild(document.createTextNode(css))
-}
-
-export function nextFrame (callback) {
- const runner = window.requestAnimationFrame
- || window.webkitRequestAnimationFrame
- || (cb => setTimeout(cb, 16))
- runner(callback)
-}
-
-export function toCSSText (object) {
- if (!object) { return }
- const obj = hyphenateStyleKeys(object)
- let cssText = ''
- for (const key in obj) {
- cssText += `${key}:${obj[key]};`
- }
- return cssText
-}