Skip to content

Commit

Permalink
fixed #3: the <component> tag doesn't redraw on is attribute update.
Browse files Browse the repository at this point in the history
  • Loading branch information
lyonlai committed Feb 4, 2018
1 parent c79a45c commit 9e95955
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "blessed-vue",
"version": "2.0.0",
"version": "2.0.1",
"description": "A VueJS runtime to render Blessed to build command line UI.",
"main": "dist/build.js",
"repository": "https://github.com/lyonlai/blessed-vue.git",
Expand Down
21 changes: 16 additions & 5 deletions src/runtime/node-ops.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,21 @@ import { refreshNode } from './util'
import { transformStaticStyle, normalizeStyleBinding } from 'util/style'

export function createElement (tagName: string, vnode: VNode) {
const isBlessed = isOverlappingTags(tagName) ? vnode.data.attrs.blessed === true : isBlessedTag(tagName)
const isBlessed = isOverlappingTags(tagName)
? vnode.data.attrs.blessed === true
: isBlessedTag(tagName)
const ctor = isBlessed ? blessed : contrib
const data = vnode.data || {}
const { staticStyle, style, attrs } = data
const el = ctor[tagName](Object.assign({ parent: vnode.elm }, attrs, {
style: staticStyle ? transformStaticStyle(staticStyle) : normalizeStyleBinding(style)
}))
const el = ctor[tagName](
Object.assign({ parent: vnode.elm }, attrs, {
style: staticStyle
? transformStaticStyle(staticStyle)
: normalizeStyleBinding(style)
})
)
el.elm = el

return el
}

Expand All @@ -27,7 +34,9 @@ export function createElementNS (namespace: string, tagName: string) {
}

export function createTextNode (text: string, options: Object = {}): Text {
return blessed['text'](Object.assign({ content: text, hidden: text.trim() === '' }, options))
return blessed['text'](
Object.assign({ content: text, hidden: text.trim() === '' }, options)
)
}

export function createComment (text: string): Comment {
Expand All @@ -36,6 +45,7 @@ export function createComment (text: string): Comment {

export function insertBefore (parentNode, newNode, referenceNode) {
parentNode.insertBefore(newNode, referenceNode)
newNode.parentNode = parentNode
continueAttributeUpdateIfRequired(newNode)
refreshNode(parentNode)
}
Expand All @@ -48,6 +58,7 @@ export function removeChild (node, child) {

export function appendChild (node, child) {
node.append(child)
child.parentNode = node
continueAttributeUpdateIfRequired(child)
refreshNode(node)
}
Expand Down
2 changes: 2 additions & 0 deletions src/util/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export class BlessedDOM {
constructor () {
this.children = []
this._events = {}
this.type = 'root-dom'
}

append (c) {
Expand All @@ -34,6 +35,7 @@ export class BlessedPlaceboElement {
constructor (parent) {
this.parent = parent
this.elm = this
this.type = 'placebo'
}

destroy () {}
Expand Down

0 comments on commit 9e95955

Please sign in to comment.