@riotjs/compiler
Advanced tools
Comparing version 4.0.2 to 4.0.3
# Compiler Changes | ||
### v4.0.3 | ||
- Fix attributes handling on custom children nodes [riot#2680](https://github.com/riot/riot/issues/2680) | ||
### v4.0.2 | ||
@@ -4,0 +8,0 @@ - Fix spread operator on each directives [riot#2679](https://github.com/riot/riot/issues/2679) |
{ | ||
"name": "@riotjs/compiler", | ||
"version": "4.0.2", | ||
"version": "4.0.3", | ||
"description": "Compiler for riot .tag files", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -119,3 +119,3 @@ import { | ||
cloneNodeWithoutSelectorAttribute(sourceNode), | ||
null, | ||
selectorAttribute, | ||
sourceFile, | ||
@@ -122,0 +122,0 @@ sourceCode |
@@ -51,3 +51,3 @@ import { | ||
cloneNodeWithoutSelectorAttribute(sourceNode), | ||
null, | ||
selectorAttribute, | ||
sourceFile, | ||
@@ -54,0 +54,0 @@ sourceCode |
@@ -19,2 +19,3 @@ import { | ||
createSelectorProperties, | ||
getAttributesWithoutSelector, | ||
getChildrenNodes, | ||
@@ -28,2 +29,3 @@ getCustomNodeNameAsExpression, | ||
import {builders} from '../../../utils/build-types' | ||
import compose from 'cumpa' | ||
import {simplePropertyNode} from '../../../utils/custom-ast-nodes' | ||
@@ -86,2 +88,3 @@ | ||
/** | ||
@@ -96,2 +99,4 @@ * Transform a RiotParser.Node.Tag into a tag binding | ||
export default function createTagBinding(sourceNode, selectorAttribute, sourceFile, sourceCode) { | ||
const createAttributeExpression = attribute => attributeExpression(attribute, sourceFile, sourceCode) | ||
return builders.objectExpression([ | ||
@@ -111,10 +116,15 @@ simplePropertyNode(BINDING_TYPE_KEY, | ||
simplePropertyNode(BINDING_SLOTS_KEY, builders.arrayExpression([ | ||
...Object.entries(groupSlots(sourceNode)) | ||
.filter(([,value]) => value) | ||
.map(([key, value]) => buildSlot(key, value, sourceFile, sourceCode)) | ||
...compose( | ||
slots => slots.map(([key, value]) => buildSlot(key, value, sourceFile, sourceCode)), | ||
slots => slots.filter(([,value]) => value), | ||
Object.entries, | ||
groupSlots | ||
)(sourceNode) | ||
])), | ||
simplePropertyNode(BINDING_ATTRIBUTES_KEY, builders.arrayExpression([ | ||
...cleanAttributes(sourceNode) | ||
.filter(attribute => attribute.name !== selectorAttribute) | ||
.map(attribute => attributeExpression(attribute, sourceFile, sourceCode)) | ||
...compose( | ||
attributes => attributes.map(createAttributeExpression), | ||
attributes => getAttributesWithoutSelector(attributes, selectorAttribute), // eslint-disable-line | ||
cleanAttributes | ||
)(sourceNode) | ||
])), | ||
@@ -121,0 +131,0 @@ ...createSelectorProperties(selectorAttribute) |
@@ -317,7 +317,21 @@ import { | ||
...node, | ||
attributes: getNodeAttributes(node).filter(attribute => attribute.name === selectorAttribute) | ||
attributes: getAttributesWithoutSelector(getNodeAttributes(node), selectorAttribute) | ||
} | ||
} | ||
/** | ||
* Get the node attributes without the selector one | ||
* @param {Array<RiotParser.Attr>} attributes - attributes list | ||
* @param {string} selectorAttribute - name of the selector attribute to filter out | ||
* @returns {Array<RiotParser.Attr>} filtered attributes | ||
*/ | ||
export function getAttributesWithoutSelector(attributes, selectorAttribute) { | ||
if (selectorAttribute) | ||
return attributes.filter(attribute => attribute.name !== selectorAttribute) | ||
return attributes | ||
} | ||
/** | ||
* Create a root node proxing only its nodes and attributes | ||
@@ -324,0 +338,0 @@ * @param {RiotParser.Node} node - riot parser node |
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
1246344
32035