Skip to content

Commit

Permalink
✨ slot feature: plain text
Browse files Browse the repository at this point in the history
  • Loading branch information
huanghuiquan committed Jun 12, 2018
1 parent d9f415e commit e5d3d7a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion packages/mip/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"dev": "node examples/server.js",
"build": "node build/build.js",
"uploadjs": "baidubce bos --put-object dist/mip.js bos://assets/mip/projects/mip.js",
"uploadcss": "baidubce bos --put-object dist/mip.css bos://assets/mip/projects/mip.css"
"uploadcss": "baidubce bos --put-object dist/mip.css bos://assets/mip/projects/mip.css",
"deploy:dev": "npm run build && npm run uploadjs && npm run uploadcss"
},
"devDependencies": {
"autoprefixer": "^8.4.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export default function createVueInstance (
{
props: this.reactiveProps
},
getSlots(element.__innerHTML, createElement)
getSlots(element.__innerHTML, createElement, this._v.bind(this))
)
}
}
Expand Down
6 changes: 3 additions & 3 deletions packages/mip/src/vue-custom-element/utils/slots.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,15 @@ export function templateElement (createElement, element, elementOptions) {
}

// Helper utility returning slots for render function
export function getSlots (innerHTML, createElement) {
export function getSlots (innerHTML, createElement, createText) {
let emptyNode = document.createElement('div')
emptyNode.innerHTML = innerHTML
let children = emptyNode.children
let children = emptyNode.childNodes
const slots = []
toArray(children).forEach(child => {
if (child.nodeName === '#text') {
if (child.nodeValue.trim()) {
slots.push(createElement('span', child.nodeValue))
slots.push(createText(child.nodeValue))
}
} else if (child.nodeName !== '#comment') {
const attributes = getAttributes(child)
Expand Down

0 comments on commit e5d3d7a

Please sign in to comment.