driver-weex
Advanced tools
Comparing version 1.0.0-beta.2 to 1.0.0-beta.3
@@ -33,3 +33,13 @@ "use strict"; | ||
var ARIA_PREFIX_REGEXP = /^aria-/; | ||
var HYPHEN_REGEXP = /\-(\w)/; | ||
var EMPTY = ''; | ||
function updateWeexTextValue(node) { | ||
var value = node.children.map(function (child) { | ||
// Comment node type | ||
return child.nodeType === 8 ? child.value : EMPTY; | ||
}).join(EMPTY); | ||
node.setAttr('value', value); | ||
} | ||
var nodeMaps = {}; | ||
@@ -60,16 +70,20 @@ /* global __weex_document__ */ | ||
function createEmpty() { | ||
return this.createComment(EMPTY); | ||
return createComment(EMPTY); | ||
} | ||
function createText(text) { | ||
return createElement(TEXT, { | ||
value: text | ||
}); | ||
// Use comment node type mock text node | ||
return createComment(text); | ||
} | ||
function updateText(node, content) { | ||
setAttribute(node, 'value', content); | ||
function updateText(node, text) { | ||
node.value = text; | ||
updateWeexTextValue(node.parentNode); | ||
} | ||
function createElement(type, props) { | ||
if (props === void 0) { | ||
props = {}; | ||
} | ||
var node = document.createElement(type, { | ||
@@ -102,3 +116,7 @@ style: props[STYLE] | ||
function appendChild(node, parent) { | ||
return parent.appendChild(node); | ||
parent.appendChild(node); | ||
if (parent.type === TEXT) { | ||
updateWeexTextValue(parent); | ||
} | ||
} | ||
@@ -114,3 +132,7 @@ | ||
return parent.removeChild(node); | ||
parent.removeChild(node); | ||
if (parent.type === TEXT) { | ||
updateWeexTextValue(parent); | ||
} | ||
} | ||
@@ -135,3 +157,7 @@ | ||
parent = parent || after.parentNode; | ||
return parent.insertAfter(node, after); | ||
parent.insertAfter(node, after); | ||
if (parent.type === TEXT) { | ||
updateWeexTextValue(parent); | ||
} | ||
} | ||
@@ -141,3 +167,7 @@ | ||
parent = parent || before.parentNode; | ||
return parent.insertBefore(node, before); | ||
parent.insertBefore(node, before); | ||
if (parent.type === TEXT) { | ||
updateWeexTextValue(parent); | ||
} | ||
} | ||
@@ -171,3 +201,3 @@ | ||
if (ARIA_PREFIX_REGEXP.test(propKey)) { | ||
propKey = propKey.replace(/\-(\w)/, function (m, p) { | ||
propKey = propKey.replace(HYPHEN_REGEXP, function (m, p) { | ||
return p.toUpperCase(); | ||
@@ -174,0 +204,0 @@ }); |
{ | ||
"name": "driver-weex", | ||
"version": "1.0.0-beta.2", | ||
"version": "1.0.0-beta.3", | ||
"description": "Weex driver for Rax", | ||
@@ -5,0 +5,0 @@ "license": "BSD-3-Clause", |
@@ -10,4 +10,14 @@ /** | ||
const ARIA_PREFIX_REGEXP = /^aria-/; | ||
const HYPHEN_REGEXP = /\-(\w)/; | ||
const EMPTY = ''; | ||
function updateWeexTextValue(node) { | ||
const value = node.children.map(function(child) { | ||
// Comment node type | ||
return child.nodeType === 8 ? child.value : EMPTY; | ||
}).join(EMPTY); | ||
node.setAttr('value', value); | ||
} | ||
const nodeMaps = {}; | ||
@@ -39,18 +49,17 @@ /* global __weex_document__ */ | ||
export function createEmpty() { | ||
return this.createComment(EMPTY); | ||
return createComment(EMPTY); | ||
} | ||
export function createText(text) { | ||
return createElement(TEXT, { | ||
value: text, | ||
}); | ||
// Use comment node type mock text node | ||
return createComment(text); | ||
} | ||
export function updateText(node, content) { | ||
setAttribute(node, 'value', content); | ||
export function updateText(node, text) { | ||
node.value = text; | ||
updateWeexTextValue(node.parentNode); | ||
} | ||
export function createElement(type, props) { | ||
export function createElement(type, props = {}) { | ||
let node = document.createElement(type, { | ||
@@ -65,3 +74,2 @@ style: props[STYLE], | ||
} | ||
if (value != null) { | ||
@@ -83,3 +91,7 @@ if (prop === STYLE) { | ||
export function appendChild(node, parent) { | ||
return parent.appendChild(node); | ||
parent.appendChild(node); | ||
if (parent.type === TEXT) { | ||
updateWeexTextValue(parent); | ||
} | ||
} | ||
@@ -93,3 +105,8 @@ | ||
} | ||
return parent.removeChild(node); | ||
parent.removeChild(node); | ||
if (parent.type === TEXT) { | ||
updateWeexTextValue(parent); | ||
} | ||
} | ||
@@ -114,3 +131,7 @@ | ||
parent = parent || after.parentNode; | ||
return parent.insertAfter(node, after); | ||
parent.insertAfter(node, after); | ||
if (parent.type === TEXT) { | ||
updateWeexTextValue(parent); | ||
} | ||
} | ||
@@ -120,3 +141,7 @@ | ||
parent = parent || before.parentNode; | ||
return parent.insertBefore(node, before); | ||
parent.insertBefore(node, before); | ||
if (parent.type === TEXT) { | ||
updateWeexTextValue(parent); | ||
} | ||
} | ||
@@ -149,3 +174,3 @@ | ||
if (ARIA_PREFIX_REGEXP.test(propKey)) { | ||
propKey = propKey.replace(/\-(\w)/, function(m, p) { | ||
propKey = propKey.replace(HYPHEN_REGEXP, function(m, p) { | ||
return p.toUpperCase(); | ||
@@ -152,0 +177,0 @@ }); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
46997
631