From 9e9595511b4d98be34b32988c4034fc373e5053e Mon Sep 17 00:00:00 2001 From: Yun Lai Date: Sun, 4 Feb 2018 23:10:46 +1100 Subject: [PATCH] fixed #3: the tag doesn't redraw on is attribute update. --- package.json | 2 +- src/runtime/node-ops.js | 21 ++++++++++++++++----- src/util/dom.js | 2 ++ 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index de691ee..aaebfba 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/runtime/node-ops.js b/src/runtime/node-ops.js index 34f3100..3392c38 100644 --- a/src/runtime/node-ops.js +++ b/src/runtime/node-ops.js @@ -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 } @@ -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 { @@ -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) } @@ -48,6 +58,7 @@ export function removeChild (node, child) { export function appendChild (node, child) { node.append(child) + child.parentNode = node continueAttributeUpdateIfRequired(child) refreshNode(node) } diff --git a/src/util/dom.js b/src/util/dom.js index e89ed85..f66a2df 100644 --- a/src/util/dom.js +++ b/src/util/dom.js @@ -10,6 +10,7 @@ export class BlessedDOM { constructor () { this.children = [] this._events = {} + this.type = 'root-dom' } append (c) { @@ -34,6 +35,7 @@ export class BlessedPlaceboElement { constructor (parent) { this.parent = parent this.elm = this + this.type = 'placebo' } destroy () {}