Socket
Socket
Sign inDemoInstall

nuejs-core

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nuejs-core - npm Package Compare versions

Comparing version 0.3.2 to 0.3.3

2

package.json
{
"name": "nuejs-core",
"version": "0.3.2",
"version": "0.3.3",

@@ -5,0 +5,0 @@ "description": "The Nue framework for building user interfaces",

@@ -34,3 +34,3 @@

str.trim().split(EXPR).map((str, i) => {
str.split(EXPR).map((str, i) => {

@@ -37,0 +37,0 @@ // normal string

@@ -88,5 +88,6 @@

// render.js only
const isJS = val => val?.constructor === Object || Array.isArray(val) || typeof val == 'function'
function isJSObject(val) {
return val?.constructor === Object || Array.isArray(val) || typeof val == 'function'
}
// exec('`font-size:${_.size + "px"}`;', data)

@@ -96,3 +97,3 @@ export function exec(expr, data={}) {

const val = fn(data)
return val == null ? '' : isJS(val) ? val : '' + val
return val == null ? '' : isJSObject(val) ? val : '' + val
}

@@ -99,0 +100,0 @@

@@ -11,3 +11,2 @@

// TypeError (evaluating '_.foo[0]') --> { text: 'TypeError', subexpr: 'foo[0]' }
function parseError(e) {

@@ -22,5 +21,8 @@ const [msg, sub] = e.toString().split("'")

function renderExpr(str, data, is_class) {
str = str.replaceAll('\n', '\\n')
try {
const arr = exec('[' + parseExpr(str) + ']', data)
return arr.filter(el => is_class ? el : el != null).join('').trim()
return arr.filter(el => is_class ? el : el != null).join('')
} catch (e) {

@@ -53,6 +55,7 @@ throw { title: 'Rendering error', expr: str, ...parseError(e) }

// attributes must be strings
/* attributes must be strings
function toString(val) {
return 1 * val ? '' + val : typeof val != 'string' ? val.toString() : val
}
*/

@@ -67,3 +70,3 @@ function setAttribute(key, attribs, data) {

// attributes must be strings
if (1 * val) val = attribs[key] = '' + val
if (val === 0 || 1 * val) val = attribs[key] = '' + val

@@ -95,4 +98,8 @@ const has_expr = val.includes('{')

// other attribute
if (value) attribs[name] = value
else delete attribs[name]
if (value) {
attribs[name] = typeof value == 'string' ? value.trim() : value
} else {
delete attribs[name]
}
delete attribs[key]

@@ -152,3 +159,3 @@ }

return key === $keys ? item || data[key] :
return key === $keys ? (item == null ? data[key] : item) :
key == $index ? items.indexOf(item) :

@@ -155,0 +162,0 @@ $keys.includes(key) ? item[key] :

@@ -21,2 +21,5 @@

runTests({
// whitespace
'<b>{ type } <i>': '<b>bold <i></i></b>',
'<b :class="type">Hey</b>': "<b class=\"bold\">Hey</b>",

@@ -28,2 +31,3 @@ '<b class="item { type }"/>': "<b class=\"item bold\"></b>",

// skip event attributes

@@ -97,3 +101,3 @@ '<a @click="click"/>': '<a></a>',

'<p :for="n in nums">{ n }</p>': '<p>1</p><p>2</p><p>3</p>',
'<p :for="n in nums">{ n }</p>': '<p>-1</p><p>0</p><p>1</p>',

@@ -111,7 +115,7 @@ '<p :for="[key, value, i] in Object.entries(person)">{ i }: { key } = { value }</p>':

'<thing :for="el in items" :bind="el"><b>{ el.age }</b></thing><u @name="thing">{name}: <slot/></u>' :
'<u>John:<b>22</b></u><u>Alice:<b>33</b></u>',
'<u>John: <b>22</b></u><u>Alice: <b>33</b></u>',
// successive loops
'<div><p :for="x in nums">{ x }</p><a :for="y in nums">{ y }</a></div>':
'<div><p>1</p><p>2</p><p>3</p><a>1</a><a>2</a><a>3</a></div>',
'<div><p>-1</p><p>0</p><p>1</p><a>-1</a><a>0</a><a>1</a></div>',

@@ -121,3 +125,3 @@ }, {

person: { name: 'Nick', email: 'nick@acme.org', age: 10 },
nums: [1, 2, 3],
nums: [-1, 0, 1],
})

@@ -175,3 +179,5 @@ })

<script>
function toLower(str) { return str.toLowerCase() }
function toLower(str) {
return str.toLowerCase()
}
</script>

@@ -181,2 +187,3 @@

{ lower(title) }
<script>

@@ -191,3 +198,4 @@ lower(str) {

const html = render(GLOBAL_SCRIPT, { title: 'Hey' })
expect(html).toBe('<div>hey</div>')
expect(html).toStartWith('<div>')
expect(html).toInclude('hey')
})

@@ -230,3 +238,2 @@

test(':for error', () => {

@@ -233,0 +240,0 @@ try {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc