@riotjs/compiler
Advanced tools
Comparing version 4.2.3 to 4.2.4
# Compiler Changes | ||
### v4.2.4 | ||
- Fix attributes on custom tags having `if` or `each` directives | ||
### v4.2.3 | ||
@@ -4,0 +7,0 @@ - Update `@riotjs/dom-bindings` using v4.0.0 |
{ | ||
"name": "@riotjs/compiler", | ||
"version": "4.2.3", | ||
"version": "4.2.4", | ||
"description": "Compiler for riot .tag files", | ||
@@ -43,3 +43,3 @@ "main": "dist/index.js", | ||
"nyc": "^14.1.1", | ||
"rollup": "^1.12.5", | ||
"rollup": "^1.13.0", | ||
"rollup-plugin-alias": "^1.5.1", | ||
@@ -49,3 +49,3 @@ "rollup-plugin-commonjs": "^10.0.0", | ||
"rollup-plugin-node-builtins": "^2.1.2", | ||
"rollup-plugin-node-resolve": "^5.0.0", | ||
"rollup-plugin-node-resolve": "^5.0.1", | ||
"shelljs": "^0.8.3" | ||
@@ -60,3 +60,3 @@ }, | ||
"dependencies": { | ||
"@riotjs/dom-bindings": "^4.0.0", | ||
"@riotjs/dom-bindings": "^4.0.1", | ||
"@riotjs/parser": "^4.0.0", | ||
@@ -63,0 +63,0 @@ "cumpa": "^1.0.1", |
@@ -109,3 +109,3 @@ import { | ||
simplePropertyNode(BINDING_CONDITION_KEY, attributeOrNull(ifAttribute)), | ||
createTemplateProperty(createNestedBindings(sourceNode, sourceFile, sourceCode)), | ||
createTemplateProperty(createNestedBindings(sourceNode, sourceFile, sourceCode, selectorAttribute)), | ||
...createSelectorProperties(selectorAttribute), | ||
@@ -112,0 +112,0 @@ ...compose(generateEachExpressionProperties, getAttributeExpression)(eachAttribute) |
@@ -41,4 +41,4 @@ import { | ||
...createSelectorProperties(selectorAttribute), | ||
createTemplateProperty(createNestedBindings(sourceNode, sourceFile, sourceCode)) | ||
createTemplateProperty(createNestedBindings(sourceNode, sourceFile, sourceCode, selectorAttribute)) | ||
]) | ||
} |
@@ -0,44 +1,13 @@ | ||
import {createAttributeExpressions, createExpression} from '../expressions/index' | ||
import { | ||
createSelectorProperties, | ||
findDynamicAttributes, | ||
getChildrenNodes, | ||
hasExpressions, | ||
isEventAttribute, | ||
isTextNode, | ||
isValueAttribute | ||
isTextNode | ||
} from '../utils' | ||
import { BINDING_EXPRESSIONS_KEY } from '../constants' | ||
import attributeExpression from '../expressions/attribute' | ||
import {builders} from '../../../utils/build-types' | ||
import eventExpression from '../expressions/event' | ||
import {simplePropertyNode} from '../../../utils/custom-ast-nodes' | ||
import textExpression from '../expressions/text' | ||
import valueExpression from '../expressions/value' | ||
function createExpression(sourceNode, sourceFile, sourceCode, childNodeIndex) { | ||
switch (true) { | ||
case isTextNode(sourceNode): | ||
return textExpression(sourceNode, sourceFile, sourceCode, childNodeIndex) | ||
case isValueAttribute(sourceNode): | ||
return valueExpression(sourceNode, sourceFile, sourceCode) | ||
case isEventAttribute(sourceNode): | ||
return eventExpression(sourceNode, sourceFile, sourceCode) | ||
default: | ||
return attributeExpression(sourceNode, sourceFile, sourceCode) | ||
} | ||
} | ||
/** | ||
* Create the attribute expressions | ||
* @param {RiotParser.Node} sourceNode - any kind of node parsed via riot parser | ||
* @param {string} sourceFile - source file path | ||
* @param {string} sourceCode - original source | ||
* @returns {Array} array containing all the attribute expressions | ||
*/ | ||
function createAttributeExpressions(sourceNode, sourceFile, sourceCode) { | ||
return findDynamicAttributes(sourceNode) | ||
.map(attribute => createExpression(attribute, sourceFile, sourceCode)) | ||
} | ||
/** | ||
* Create the text node expressions | ||
@@ -45,0 +14,0 @@ * @param {RiotParser.Node} sourceNode - any kind of node parsed via riot parser |
@@ -25,6 +25,6 @@ import { | ||
} from '../utils' | ||
import attributeExpression from '../expressions/attribute' | ||
import build from '../builder' | ||
import {builders} from '../../../utils/build-types' | ||
import compose from 'cumpa' | ||
import {createExpression} from '../expressions/index' | ||
import {simplePropertyNode} from '../../../utils/custom-ast-nodes' | ||
@@ -105,7 +105,5 @@ | ||
function createBindingAttributes(sourceNode, selectorAttribute, sourceFile, sourceCode) { | ||
const createAttributeExpression = attribute => attributeExpression(attribute, sourceFile, sourceCode) | ||
return builders.arrayExpression([ | ||
...compose( | ||
attributes => attributes.map(createAttributeExpression), | ||
attributes => attributes.map(attribute => createExpression(attribute, sourceFile, sourceCode)), | ||
attributes => getAttributesWithoutSelector(attributes, selectorAttribute), // eslint-disable-line | ||
@@ -112,0 +110,0 @@ cleanAttributes |
@@ -121,5 +121,6 @@ import { | ||
* @param { string } sourceCode - original source | ||
* @param { string } selector - binding selector | ||
* @returns { Array } array with only the tag binding AST | ||
*/ | ||
export function createNestedBindings(sourceNode, sourceFile, sourceCode) { | ||
export function createNestedBindings(sourceNode, sourceFile, sourceCode, selector) { | ||
const mightBeARiotComponent = isCustomNode(sourceNode) | ||
@@ -129,3 +130,3 @@ | ||
tagBinding( | ||
cloneNodeWithoutSelectorAttribute(sourceNode), | ||
cloneNodeWithoutSelectorAttribute(sourceNode, selector), | ||
null, | ||
@@ -132,0 +133,0 @@ sourceFile, |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1263675
48
32477
Updated@riotjs/dom-bindings@^4.0.1