jsio('from shared.javascript import Class, bind')
jsio('import ui.Component')

exports = Class(ui.Component, function(supr){
	
	this._domTag = 'span'
	this._className = 'Value'
	
	this.init = function(jsArgs, viewArgs) {
		supr(this, 'init')
		
		this._itemIds = jsArgs[0]
		this._property = viewArgs[0]
	}
	
	this._createContent = function() {
		this.setDependant(this._itemIds, this._property)
	}
	
	this.setDependant = function(itemIds, property) {
		if (this._item) { logger.warn("TODO unsubscribe from old item") }
		this._propertyChain = property.split('.')
		var itemId = (typeof itemIds == 'string' ? itemIds 
				: itemIds.getId ? itemIds.getId()
				: itemIds[this._propertyChain.shift()])
		this._item = fin.getItem(itemId)
		this._item.addDependant(this._propertyChain, bind(this, '_onItemMutation'))
	}
	
	this._onItemMutation = function(mutation, newValue) {
		this.setValue(newValue)
	}
	
	this.setValue = function(value) {
		if (typeof value == 'undefined') { return }
		value = value.replace(/\n/g, '<br />')
		value = value.replace(/ $/, '&nbsp;')
		this._element.innerHTML = value
	}
})
@@ -978,16 +978,51 @@
 eturn %7D%0A
+%09%09if (typeof value == 'string') %7B%0A%09
 %09%09value 
@@ -1054,16 +1054,17 @@
 br /%3E')%0A
+%09
 %09%09value 
@@ -1095,16 +1095,20 @@
 nbsp;')%0A
+%09%09%7D%0A
 %09%09this._

Fix linebreaks only for string values