Skip to content

Commit

Permalink
Merge branch 'master' into android-feature-dev-tools-exception
Browse files Browse the repository at this point in the history
* master:
  * [ios] refix transform's parse bug about translate close apache#898, close apache#903, close apache#907, close apache#883
  * [android] fix pseudo status can not restore
  [WEEX-139][ios]Provide system language infomation
  * [html5] bugfix:   - fix waterfall: use headers below cells as footers.   - fix issue WEEX-97.   - fix click handler being invoked twice for switch.
  • Loading branch information
atomtong committed Nov 23, 2017
2 parents 01d6889 + 0535ac6 commit 3f24365
Show file tree
Hide file tree
Showing 14 changed files with 189 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public void executeDom(DOMActionContext context) {


if (!mData.isEmpty()) {
domObject.updateStyle(mData);
domObject.updateStyle(mData, mIsCausedByPesudo);
domObject.applyStyle(mData);
if(!mData.isEmpty()) {
context.postRenderTask(this);
Expand Down
6 changes: 5 additions & 1 deletion html5/render/vue/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,11 +193,15 @@ vue: {

* fix image lazyloading.

#### 0.12.23
#### 0.12.24

* add try catch to accessing localStorage.
* support image sprite.

#### 0.12.25

* fix indicator position in one page slider.

## component -> dom map

| component | dom element | children | note |
Expand Down
45 changes: 38 additions & 7 deletions html5/render/vue/components/scrollable/waterfall.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,35 +93,66 @@ function getWaterfall (weex) {
_createChildren (h, rootStyle) {
const slots = this.$slots.default || []
this._headers = []
this._footers = []
this._others = []
const len = slots.length

for (let i = 0; i < len; i++) {
const vnode = slots[i]
const tag = vnode.componentOptions && vnode.componentOptions.tag
if (tag === 'refresh' || tag === 'loading') {
continue
}
if (tag === 'cell') {
break
}
if (tag === 'header') {
this._headers.push(vnode)
}
}

for (let i = len - 1; i >= 0; i--) {
const vnode = slots[i]
const tag = vnode.componentOptions && vnode.componentOptions.tag
if (tag === 'refresh' || tag === 'loading') {
continue
}
if (tag === 'cell') {
break
}
if (tag === 'header') {
this._footers.push(vnode)
}
}

this._cells = slots.filter(vnode => {
if (!vnode.tag || !vnode.componentOptions) return false
const tag = vnode.componentOptions.tag
if (tag === 'refresh' || tag === 'loading') {
this[`_${tag}`] = vnode
return false
}
if (tag === 'header') {
this._headers.push(vnode)
return false
}
if (tag !== 'cell') {
this._others.push(vnode)
return false
}
return true
})

this._reCalc(rootStyle)
this._genColumns(h)
let children = []
this._refresh && children.push(this._refresh)
children = children
.concat(this._headers)
.concat(this._others)
children = children.concat(this._headers)
// .concat(this._others)
children.push(h('html:div', {
ref: 'columns',
staticClass: 'weex-waterfall-inner-columns weex-ct'
}, this._columns))
children.push(h('html:div', {
ref: 'footers',
staticClass: 'weex-waterfall-footers weex-ct'
}, this._footers))
this._loading && children.push(this._loading)
return [
h('article', {
Expand Down
27 changes: 21 additions & 6 deletions html5/render/vue/components/switch.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,19 +115,34 @@ function getSwitch (weex) {
}
},

mounted () {
const el = this.$el
if (el && el.nodeType === 1) {
if (!this._removeClickHandler) {
const handler = evt => {
this.toggle()
}
this._removeClickHandler = el.removeEventListener.bind(el, 'click', handler)
el.addEventListener('click', handler)
}
}
},

beforeDestroy () {
const rm = this._removeClickHandler
if (rm) {
rm()
delete this._removeClickHandler
}
},

render (createElement) {
/* istanbul ignore next */
// if (process.env.NODE_ENV === 'development') {
// validateStyles('switch', this.$vnode.data && this.$vnode.data.staticStyle)
// }
return createElement('span', {
attrs: { 'weex-type': 'switch' },
on: {
click: event => {
this.$emit('click', event)
this.toggle()
}
},
staticClass: this.wrapperClass,
staticStyle: extractComponentStyle(this)
}, [createElement('small', { staticClass: 'weex-switch-inner' })])
Expand Down
24 changes: 15 additions & 9 deletions html5/render/vue/core/style.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,13 +225,13 @@ export function getComponentStyle (context, extract) {
}
return {}
}
let style = {}
const style = {}
let vnode = context.$vnode
while (vnode) {
extend(style, getStyle(vnode, extract))
vnode = vnode.parent
}
style = autoPrefix(style)
const prefixedStyle = autoPrefix(style)
/**
* when prefixed value is a array, it should be applied to element
* during the next tick.
Expand All @@ -245,9 +245,9 @@ export function getComponentStyle (context, extract) {
* "linear-gradient(to top,#f5fefd,#ffffff)"]
* }
*/
for (const k in style) {
if (Array.isArray(style[k])) {
const vals = style[k]
for (const k in prefixedStyle) {
if (Array.isArray(prefixedStyle[k])) {
const vals = prefixedStyle[k]
context.$nextTick(function () {
const el = context.$el
if (el) {
Expand All @@ -256,14 +256,20 @@ export function getComponentStyle (context, extract) {
}
}
})
if (k !== 'position') { delete style[k] }
if (k !== 'position') {
/**
* Should not delete prefixedStyle[k] directly. Otherwise will
* trigger issue: https://issues.apache.org/jira/projects/WEEX/issues/WEEX-97
*/
prefixedStyle[k] = style[k]
}
}
}

/**
* If position is 'sticky', then add it to the stickyChildren of the parent scroller.
*/
const pos = style.position
const pos = prefixedStyle.position
const reg = /sticky$/
if (pos === 'fixed') {
context.$nextTick(function () {
Expand All @@ -274,7 +280,7 @@ export function getComponentStyle (context, extract) {
})
}
else if (isArray(pos) && pos[0].match(reg) || (pos + '').match(reg)) {
delete style.position
delete prefixedStyle.position
// use native sticky.
if (supportSticky()) {
context.$nextTick(function () {
Expand Down Expand Up @@ -304,7 +310,7 @@ export function getComponentStyle (context, extract) {
}
}

return style
return prefixedStyle
}

export function extractComponentStyle (context) {
Expand Down
12 changes: 12 additions & 0 deletions ios/sdk/WeexSDK.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,10 @@
841CD1061F974DFA0081196D /* WXExceptionUtils.h in Headers */ = {isa = PBXBuildFile; fileRef = 841CD1041F97399C0081196D /* WXExceptionUtils.h */; settings = {ATTRIBUTES = (Public, ); }; };
841CD1071F974E000081196D /* WXExceptionUtils.m in Sources */ = {isa = PBXBuildFile; fileRef = 841CD1021F9739890081196D /* WXExceptionUtils.m */; };
9B9E74791FA2DB5800DAAEA9 /* WXTestBridgeMethodDummy.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B9E74781FA2DB5800DAAEA9 /* WXTestBridgeMethodDummy.m */; };
BA5F00F11FC5AFFE00F76B5C /* WXLocaleModule.h in Headers */ = {isa = PBXBuildFile; fileRef = BA5F00EF1FC5AFFE00F76B5C /* WXLocaleModule.h */; };
BA5F00F21FC5AFFE00F76B5C /* WXLocaleModule.m in Sources */ = {isa = PBXBuildFile; fileRef = BA5F00F01FC5AFFE00F76B5C /* WXLocaleModule.m */; };
BA5F00F31FC6834900F76B5C /* WXLocaleModule.h in Headers */ = {isa = PBXBuildFile; fileRef = BA5F00EF1FC5AFFE00F76B5C /* WXLocaleModule.h */; };
BA5F00F41FC6834C00F76B5C /* WXLocaleModule.m in Sources */ = {isa = PBXBuildFile; fileRef = BA5F00F01FC5AFFE00F76B5C /* WXLocaleModule.m */; };
C401945E1E344E8300D19C31 /* WXFloatCompareTests.m in Sources */ = {isa = PBXBuildFile; fileRef = C401945D1E344E8300D19C31 /* WXFloatCompareTests.m */; };
C41E1A971DC1FD15009C7F90 /* WXDatePickerManager.h in Headers */ = {isa = PBXBuildFile; fileRef = C41E1A951DC1FD15009C7F90 /* WXDatePickerManager.h */; };
C41E1A981DC1FD15009C7F90 /* WXDatePickerManager.m in Sources */ = {isa = PBXBuildFile; fileRef = C41E1A961DC1FD15009C7F90 /* WXDatePickerManager.m */; };
Expand Down Expand Up @@ -860,6 +864,8 @@
841CD1041F97399C0081196D /* WXExceptionUtils.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WXExceptionUtils.h; sourceTree = "<group>"; };
9B9E74771FA2DB5800DAAEA9 /* WXTestBridgeMethodDummy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WXTestBridgeMethodDummy.h; sourceTree = "<group>"; };
9B9E74781FA2DB5800DAAEA9 /* WXTestBridgeMethodDummy.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WXTestBridgeMethodDummy.m; sourceTree = "<group>"; };
BA5F00EF1FC5AFFE00F76B5C /* WXLocaleModule.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WXLocaleModule.h; sourceTree = "<group>"; };
BA5F00F01FC5AFFE00F76B5C /* WXLocaleModule.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = WXLocaleModule.m; sourceTree = "<group>"; };
C401945D1E344E8300D19C31 /* WXFloatCompareTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WXFloatCompareTests.m; sourceTree = "<group>"; };
C41E1A951DC1FD15009C7F90 /* WXDatePickerManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WXDatePickerManager.h; sourceTree = "<group>"; };
C41E1A961DC1FD15009C7F90 /* WXDatePickerManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WXDatePickerManager.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1411,6 +1417,8 @@
77E659D71C07F585008B8775 /* Module */ = {
isa = PBXGroup;
children = (
BA5F00EF1FC5AFFE00F76B5C /* WXLocaleModule.h */,
BA5F00F01FC5AFFE00F76B5C /* WXLocaleModule.m */,
DCE2CF981F46D4220021BDC4 /* WXVoiceOverModule.m */,
DCE2CF991F46D4220021BDC4 /* WXVoiceOverModule.h */,
333D9A251F41507A007CED39 /* WXTransition.h */,
Expand Down Expand Up @@ -1701,6 +1709,7 @@
74D205201E091B8000128F44 /* WXCallJSMethod.h in Headers */,
741DFE061DDD9B30009B020F /* UIBezierPath+Weex.h in Headers */,
2AAFC1B61C48DFF70026D2FE /* WXSDKError.h in Headers */,
BA5F00F11FC5AFFE00F76B5C /* WXLocaleModule.h in Headers */,
742AD72E1DF98C45007DC46C /* WXResourceRequest.h in Headers */,
D317338C1C57257000BB7539 /* WXTransform.h in Headers */,
77D161301C02DE4E0010B15B /* WXComponent.h in Headers */,
Expand Down Expand Up @@ -1776,6 +1785,7 @@
DCA445EC1EFA5A0E00D0CFA8 /* WXTextAreaComponent.h in Headers */,
DCA445D81EFA599400D0CFA8 /* WXRootView.h in Headers */,
DCA446131EFA5A8C00D0CFA8 /* WXCallJSMethod.h in Headers */,
BA5F00F31FC6834900F76B5C /* WXLocaleModule.h in Headers */,
74B81AED1F73C3E900D3A61D /* WXCellSlotComponent.h in Headers */,
DCA445E41EFA59DC00D0CFA8 /* WXVideoComponent.h in Headers */,
DCA4460B1EFA5A7200D0CFA8 /* WXAssert.h in Headers */,
Expand Down Expand Up @@ -2141,6 +2151,7 @@
744BEA5A1D0520F300452B5D /* WXComponent+Layout.m in Sources */,
59A582FD1CF5B17B0081FD3E /* WXBridgeContext.m in Sources */,
743933B51C7ED9AA00773BB7 /* WXSimulatorShortcutManager.m in Sources */,
BA5F00F21FC5AFFE00F76B5C /* WXLocaleModule.m in Sources */,
74BB5FBA1DFEE81A004FC3DF /* WXMetaModule.m in Sources */,
741081201CED585A001BC6E5 /* WXComponentManager.m in Sources */,
1D3000F21D40B9AC004F3B4F /* WXClipboardModule.m in Sources */,
Expand Down Expand Up @@ -2237,6 +2248,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
BA5F00F41FC6834C00F76B5C /* WXLocaleModule.m in Sources */,
DCA4452D1EFA55B300D0CFA8 /* WXComponent+Layout.m in Sources */,
DCA4452F1EFA55B300D0CFA8 /* WXResourceLoader.m in Sources */,
DCA445301EFA55B300D0CFA8 /* WXComponent+Events.m in Sources */,
Expand Down
35 changes: 15 additions & 20 deletions ios/sdk/WeexSDK/Sources/Component/WXTransform.m
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,6 @@ - (void)parseTransformOrigin:(NSString *)cssValue
}
}
}

_originX = [WXLength lengthWithFloat:originX type:typeX];
_originY = [WXLength lengthWithFloat:originY type:typeY];
}
Expand Down Expand Up @@ -347,6 +346,12 @@ - (void)parsePerspective:(NSArray *)value
}

- (void)parseTranslate:(NSArray *)value
{
[self parseTranslatex:@[value[0]]];
[self parseTranslatey:@[value[1]]];
}

- (void)parseTranslatex:(NSArray *)value
{
WXLength *translateX;
double x = [value[0] doubleValue];
Expand All @@ -356,30 +361,20 @@ - (void)parseTranslate:(NSArray *)value
x = WXPixelScale(x, self.weexInstance.pixelScaleFactor);
translateX = [WXLength lengthWithFloat:x type:WXLengthTypeFixed];
}

WXLength *translateY;
if (value.count > 1) {
double y = [value[1] doubleValue];
if ([value[1] hasSuffix:@"%"]) {
translateY = [WXLength lengthWithFloat:y type:WXLengthTypePercent];
} else {
y = WXPixelScale(y, self.weexInstance.pixelScaleFactor);
translateY = [WXLength lengthWithFloat:y type:WXLengthTypeFixed];
}
}

_translateX = translateX;
_translateY = translateY;
}

- (void)parseTranslatex:(NSArray *)value
{
[self parseTranslate:@[value[0], @"0"]];
}

- (void)parseTranslatey:(NSArray *)value
{
[self parseTranslate:@[@"0", value[0]]];
WXLength *translateY;
double y = [value[0] doubleValue];
if ([value[0] hasSuffix:@"%"]) {
translateY = [WXLength lengthWithFloat:y type:WXLengthTypePercent];
} else {
y = WXPixelScale(y, self.weexInstance.pixelScaleFactor);
translateY = [WXLength lengthWithFloat:y type:WXLengthTypeFixed];
}
_translateY = translateY;
}

- (void)parseScale:(NSArray *)value
Expand Down
1 change: 1 addition & 0 deletions ios/sdk/WeexSDK/Sources/Engine/WXSDKEngine.m
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ @implementation WXSDKEngine
+ (void)_registerDefaultModules
{
[self registerModule:@"dom" withClass:NSClassFromString(@"WXDomModule")];
[self registerModule:@"locale" withClass:NSClassFromString(@"WXLocaleModule")];
[self registerModule:@"navigator" withClass:NSClassFromString(@"WXNavigatorModule")];
[self registerModule:@"stream" withClass:NSClassFromString(@"WXStreamModule")];
[self registerModule:@"animation" withClass:NSClassFromString(@"WXAnimationModule")];
Expand Down
27 changes: 27 additions & 0 deletions ios/sdk/WeexSDK/Sources/Module/WXLocaleModule.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

#import <Foundation/Foundation.h>
#import "WXModuleProtocol.h"

/**
Provide system language information.
*/
@interface WXLocaleModule : NSObject <WXModuleProtocol>
@end

0 comments on commit 3f24365

Please sign in to comment.