@dolphinweex/weex-vue-render 0.1.6 → 0.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,6 +8,21 @@ console.log('START WEEX VUE RENDER: 1.0.36, Build 2018-12-29 17:52.');
8
8
  (global.WeexVueRender = factory());
9
9
  }(this, (function () { 'use strict';
10
10
 
11
+ function isAbsoluteOrFixedPositioned(element, deep=2) {
12
+ let currentElement = element;
13
+
14
+ let deep_ = 0;
15
+ while (currentElement && deep_ <= deep) {
16
+ deep_++;
17
+ const position = window.getComputedStyle(currentElement).position;
18
+ if (position === 'absolute' || position === 'fixed') {
19
+ return true;
20
+ }
21
+ currentElement = currentElement.parentElement;
22
+ }
23
+ return false;
24
+ }
25
+
11
26
  function __$styleInject(css, returnValue) {
12
27
  if (typeof document === 'undefined') {
13
28
  return returnValue;
@@ -4827,9 +4842,27 @@ var bindingStyleNamesForPx2Rem$1 = config.bindingStyleNamesForPx2Rem;
4827
4842
 
4828
4843
  var style = {
4829
4844
  methods: {
4845
+ _deepClone: function(obj) {
4846
+ if (typeof obj !== 'object') {
4847
+ return obj; // 基本类型直接返回
4848
+ }
4849
+ if (Array.isArray(obj)) {
4850
+ const arrCopy = [];
4851
+ for (let i = 0; i < obj.length; i++) {
4852
+ arrCopy[i] = this._deepClone(obj[i]);
4853
+ }
4854
+ return arrCopy;
4855
+ }
4856
+ const objCopy = {};
4857
+ for (const key in obj) {
4858
+ if (obj.hasOwnProperty(key)) {
4859
+ objCopy[key] = this._deepClone(obj[key]);
4860
+ }
4861
+ }
4862
+ return objCopy;
4863
+ },
4830
4864
  _px2rem: function _px2rem (value, rootValue) {
4831
4865
  var this$1 = this;
4832
-
4833
4866
  if (typeof value === 'string') {
4834
4867
  return (value + '').replace(/[+-]?\d+(?:.\d*)?[pw]x/gi, function ($0) {
4835
4868
  return weex.utils.px2rem($0, rootValue)
@@ -4839,21 +4872,23 @@ var style = {
4839
4872
  return weex.utils.px2rem(value + '', rootValue)
4840
4873
  }
4841
4874
  if (isPlainObject(value)) {
4842
- for (var k in value) {
4875
+ let cloneObj = this._deepClone(value)
4876
+ for (var k in cloneObj) {
4843
4877
  if (
4844
- value.hasOwnProperty(k)
4878
+ cloneObj.hasOwnProperty(k)
4845
4879
  && bindingStyleNamesForPx2Rem$1.indexOf(k) > -1
4846
4880
  ) {
4847
- value[k] = weex.utils.px2rem(value[k] + '', rootValue);
4881
+ cloneObj[k] = weex.utils.px2rem(cloneObj[k] + '', rootValue);
4848
4882
  }
4849
4883
  }
4850
- return value
4884
+ return cloneObj
4851
4885
  }
4852
4886
  if (isArray(value)) {
4853
- for (var i = 0, l = value.length; i < l; i++) {
4854
- this$1._px2rem(value[i], rootValue);
4887
+ let cloneArr = this._deepClone(value)
4888
+ for (var i = 0, l = cloneArr.length; i < l; i++) {
4889
+ this$1._px2rem(cloneArr[i], rootValue);
4855
4890
  }
4856
- return value
4891
+ return cloneArr
4857
4892
  }
4858
4893
  },
4859
4894
 
@@ -5907,10 +5942,14 @@ function getList (weex) {
5907
5942
  },
5908
5943
  mounted: function mounted () {
5909
5944
  var this$1 = this;
5910
- var position = window.getComputedStyle(this$1.$el).position;
5911
- if (position == "absolute") {
5945
+ if (isAbsoluteOrFixedPositioned(this$1.$el)) {
5912
5946
  this$1.$el.classList.remove("height-0");
5913
5947
  }
5948
+ setTimeout(() => {
5949
+ if (this$1.$el.clientHeight == 0) {
5950
+ this$1.$el.classList.remove("height-0");
5951
+ }
5952
+ }, 0);
5914
5953
  },
5915
5954
  methods: {
5916
5955
  createChildren: function createChildren (h) {
@@ -5999,10 +6038,14 @@ function getScroller (weex) {
5999
6038
  },
6000
6039
  mounted: function mounted () {
6001
6040
  var this$1 = this;
6002
- var position = window.getComputedStyle(this$1.$el).position;
6003
- if (position == "absolute") {
6041
+ if (isAbsoluteOrFixedPositioned(this$1.$el)) {
6004
6042
  this$1.$el.classList.remove("height-0");
6005
6043
  }
6044
+ setTimeout(() => {
6045
+ if (this$1.$el.clientHeight == 0) {
6046
+ this$1.$el.classList.remove("height-0");
6047
+ }
6048
+ }, 0);
6006
6049
  },
6007
6050
  computed: {
6008
6051
  wrapperClass: function wrapperClass () {
@@ -6911,10 +6954,14 @@ function getList$1 (weex) {
6911
6954
  },
6912
6955
  mounted: function mounted () {
6913
6956
  var this$1 = this;
6914
- var position = window.getComputedStyle(this$1.$el).position;
6915
- if (position == "absolute") {
6957
+ if (isAbsoluteOrFixedPositioned(this$1.$el)) {
6916
6958
  this$1.$el.classList.remove("height-0");
6917
6959
  }
6960
+ setTimeout(() => {
6961
+ if (this$1.$el.clientHeight == 0) {
6962
+ this$1.$el.classList.remove("height-0");
6963
+ }
6964
+ }, 0);
6918
6965
  },
6919
6966
  computed: {
6920
6967
  wrapperClass: function wrapperClass () {
package/package.json CHANGED
@@ -49,5 +49,5 @@
49
49
  "type": "git",
50
50
  "url": "git+ssh://git@github.com/weexteam/weex-vue-render.git"
51
51
  },
52
- "version": "0.1.6"
52
+ "version": "0.1.8"
53
53
  }