Skip to content

Commit 2639d70

Browse files
committed
fix(weex): use document instead of renderer to create Element
1 parent fea505a commit 2639d70

File tree

4 files changed

+16
-27
lines changed

4 files changed

+16
-27
lines changed

build/config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const banner =
1717

1818
const weexFactoryPlugin = {
1919
intro () {
20-
return 'module.exports = function weexFactory (exports, renderer) {'
20+
return 'module.exports = function weexFactory (exports, document) {'
2121
},
2222
outro () {
2323
return '}'

src/platforms/weex/entry-framework.js

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,19 @@
1-
import TextNode from 'weex/runtime/text-node'
2-
31
// this will be preserved during build
42
const VueFactory = require('./factory')
53

64
const instances = {}
75

8-
const renderer = {
9-
TextNode
10-
}
11-
126
/**
13-
* Prepare framework config, basically about the virtual-DOM and JS bridge.
14-
* @param {object} cfg
7+
* Prepare framework config.
8+
* Nothing need to do actually, just an interface provided to weex runtime.
159
*/
16-
export function init (cfg) {
17-
renderer.Document = cfg.Document
18-
renderer.Element = cfg.Element
19-
renderer.Comment = cfg.Comment
20-
}
10+
export function init () {}
2111

2212
/**
2313
* Reset framework config and clear all registrations.
2414
*/
2515
export function reset () {
2616
clear(instances)
27-
delete renderer.Document
28-
delete renderer.Element
29-
delete renderer.Comment
3017
}
3118

3219
/**
@@ -182,7 +169,7 @@ export function receiveTasks (id, tasks) {
182169
*/
183170
function createVueModuleInstance (instanceId, weex) {
184171
const exports = {}
185-
VueFactory(exports, renderer)
172+
VueFactory(exports, weex.document)
186173
const Vue = exports.Vue
187174

188175
const instance = instances[instanceId]

src/platforms/weex/runtime/node-ops.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,24 @@
1-
/* globals renderer */
2-
// renderer is injected by weex factory wrapper
1+
/* globals document */
2+
// document is injected by weex factory wrapper
3+
4+
import TextNode from 'weex/runtime/text-node'
35

46
export const namespaceMap = {}
57

68
export function createElement (tagName) {
7-
return new renderer.Element(tagName)
9+
return document.createElement(tagName)
810
}
911

1012
export function createElementNS (namespace, tagName) {
11-
return new renderer.Element(namespace + ':' + tagName)
13+
return document.createElement(namespace + ':' + tagName)
1214
}
1315

1416
export function createTextNode (text) {
15-
return new renderer.TextNode(text)
17+
return new TextNode(text)
1618
}
1719

1820
export function createComment (text) {
19-
return new renderer.Comment(text)
21+
return document.createComment(text)
2022
}
2123

2224
export function insertBefore (node, target, before) {

src/platforms/weex/util/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* globals renderer */
1+
/* globals document */
22

33
import { makeMap } from 'shared/util'
44

@@ -34,8 +34,8 @@ export function getTagNamespace () { /* console.log('getTagNamespace') */ }
3434
export function isUnknownElement () { /* console.log('isUnknownElement') */ }
3535

3636
export function query (el, document) {
37-
// renderer is injected by weex factory wrapper
38-
const placeholder = new renderer.Comment('root')
37+
// document is injected by weex factory wrapper
38+
const placeholder = document.createComment('root')
3939
placeholder.hasAttribute = placeholder.removeAttribute = function () {} // hack for patch
4040
document.documentElement.appendChild(placeholder)
4141
return placeholder

0 commit comments

Comments
 (0)