@riotjs/compiler
Advanced tools
Comparing version 4.3.12 to 4.4.0
# Compiler Changes | ||
### v4.4.0 | ||
- Add allow the use of attributes on slot tags | ||
### v4.3.12 | ||
- Fix https://github.com/riot/riot/issues/2760 | ||
### v4.3.11 | ||
@@ -4,0 +10,0 @@ - Fix https://github.com/riot/compiler/issues/127 |
{ | ||
"name": "@riotjs/compiler", | ||
"version": "4.3.12", | ||
"version": "4.4.0", | ||
"description": "Compiler for riot .tag files", | ||
@@ -36,2 +36,3 @@ "main": "dist/index.js", | ||
"devDependencies": { | ||
"@riotjs/dom-bindings": "^4.3.0", | ||
"chai": "^4.2.0", | ||
@@ -59,4 +60,4 @@ "coveralls": "^3.0.6", | ||
"dependencies": { | ||
"@riotjs/dom-bindings": "^4.3.0", | ||
"@riotjs/parser": "^4.0.3", | ||
"@riotjs/parser": "^4.1.0", | ||
"@riotjs/util": "1.1.0", | ||
"acorn": "^7.0.0", | ||
@@ -63,0 +64,0 @@ "cssesc": "^3.0.0", |
@@ -26,3 +26,3 @@ import { | ||
import generateJavascript from '../../../utils/generate-javascript' | ||
import panic from '../../../utils/panic' | ||
import {panic} from '@riotjs/util/misc' | ||
@@ -29,0 +29,0 @@ const getEachItemName = expression => isSequenceExpression(expression.left) ? expression.left.expressions[0] : expression.left |
import { | ||
BINDING_ATTRIBUTES_KEY, | ||
BINDING_NAME_KEY, | ||
@@ -9,4 +10,4 @@ BINDING_TYPES, | ||
} from '../constants' | ||
import {createBindingAttributes, createSelectorProperties} from '../utils' | ||
import {builders} from '../../../utils/build-types' | ||
import {createSelectorProperties} from '../utils' | ||
import {findAttribute} from '../find' | ||
@@ -19,5 +20,7 @@ import {simplePropertyNode} from '../../../utils/custom-ast-nodes' | ||
* @param { string } selectorAttribute - attribute needed to select the target node | ||
* @param { string } sourceFile - source file path | ||
* @param { string } sourceCode - original source | ||
* @returns { AST.Node } a slot binding node | ||
*/ | ||
export default function createSlotBinding(sourceNode, selectorAttribute) { | ||
export default function createSlotBinding(sourceNode, selectorAttribute, sourceFile, sourceCode) { | ||
const slotNameAttribute = findAttribute(NAME_ATTRIBUTE, sourceNode) | ||
@@ -35,2 +38,6 @@ const slotName = slotNameAttribute ? slotNameAttribute.value : DEFAULT_SLOT_NAME | ||
simplePropertyNode( | ||
BINDING_ATTRIBUTES_KEY, | ||
createBindingAttributes(sourceNode, selectorAttribute, sourceFile, sourceCode) | ||
), | ||
simplePropertyNode( | ||
BINDING_NAME_KEY, | ||
@@ -37,0 +44,0 @@ builders.literal(slotName) |
@@ -16,6 +16,5 @@ import { | ||
import { | ||
cleanAttributes, | ||
createBindingAttributes, | ||
createRootNode, | ||
createSelectorProperties, | ||
getAttributesWithoutSelector, | ||
getChildrenNodes, | ||
@@ -29,3 +28,2 @@ getCustomNodeNameAsExpression, | ||
import compose from 'cumpa' | ||
import {createExpression} from '../expressions/index' | ||
import {simplePropertyNode} from '../../../utils/custom-ast-nodes' | ||
@@ -98,20 +96,2 @@ | ||
/** | ||
* Create the AST array containing the attributes to bind to this node | ||
* @param { RiotParser.Node.Tag } sourceNode - the custom tag | ||
* @param { string } selectorAttribute - attribute needed to select the target node | ||
* @param { string } sourceFile - source file path | ||
* @param { string } sourceCode - original source | ||
* @returns {AST.ArrayExpression} array containing the slot objects | ||
*/ | ||
function createBindingAttributes(sourceNode, selectorAttribute, sourceFile, sourceCode) { | ||
return builders.arrayExpression([ | ||
...compose( | ||
attributes => attributes.map(attribute => createExpression(attribute, sourceFile, sourceCode, 0, sourceNode)), | ||
attributes => getAttributesWithoutSelector(attributes, selectorAttribute), | ||
cleanAttributes | ||
)(sourceNode) | ||
]) | ||
} | ||
/** | ||
* Find the slot attribute if it exists | ||
@@ -118,0 +98,0 @@ * @param {RiotParser.Node.Tag} sourceNode - the custom tag |
@@ -23,3 +23,3 @@ import { | ||
import ifBinding from './bindings/if' | ||
import panic from '../../utils/panic' | ||
import {panic} from '@riotjs/util/misc' | ||
import simpleBinding from './bindings/simple' | ||
@@ -26,0 +26,0 @@ import slotBinding from './bindings/slot' |
@@ -1,2 +0,2 @@ | ||
// import {IS_BOOLEAN,IS_CUSTOM,IS_RAW,IS_SPREAD,IS_VOID} from '@riotjs/parser/src/constants' | ||
import {constants} from '@riotjs/parser' | ||
@@ -51,3 +51,3 @@ export const BINDING_TYPES = 'bindingTypes' | ||
export const DEFAULT_SLOT_NAME = 'default' | ||
export const TEXT_NODE_EXPRESSION_PLACEHOLDER = '<!---->' | ||
export const TEXT_NODE_EXPRESSION_PLACEHOLDER = ' ' | ||
export const BINDING_SELECTOR_PREFIX = 'expr' | ||
@@ -58,9 +58,8 @@ export const SLOT_TAG_NODE_NAME = 'slot' | ||
// Riot Parser constants | ||
// TODO: import these values dynamically | ||
export const IS_RAW_NODE = 'isRaw' | ||
export const IS_VOID_NODE = 'isVoid' | ||
export const IS_CUSTOM_NODE = 'isCustom' | ||
export const IS_BOOLEAN_ATTRIBUTE = 'isBoolean' | ||
export const IS_SPREAD_ATTRIBUTE = 'isSpread' | ||
export const IS_RAW_NODE = constants.IS_RAW | ||
export const IS_VOID_NODE = constants.IS_VOID | ||
export const IS_CUSTOM_NODE = constants.IS_CUSTOM | ||
export const IS_BOOLEAN_ATTRIBUTE = constants.IS_BOOLEAN | ||
export const IS_SPREAD_ATTRIBUTE = constants.IS_SPREAD | ||
@@ -23,2 +23,3 @@ import { | ||
import compose from 'cumpa' | ||
import {createExpression} from './expressions/index' | ||
import generateAST from '../../utils/generate-ast' | ||
@@ -469,2 +470,20 @@ import unescapeChar from '../../utils/unescape-char' | ||
/** | ||
* Create the AST array containing the attributes to bind to this node | ||
* @param { RiotParser.Node.Tag } sourceNode - the custom tag | ||
* @param { string } selectorAttribute - attribute needed to select the target node | ||
* @param { string } sourceFile - source file path | ||
* @param { string } sourceCode - original source | ||
* @returns {AST.ArrayExpression} array containing the slot objects | ||
*/ | ||
export function createBindingAttributes(sourceNode, selectorAttribute, sourceFile, sourceCode) { | ||
return builders.arrayExpression([ | ||
...compose( | ||
attributes => attributes.map(attribute => createExpression(attribute, sourceFile, sourceCode, 0, sourceNode)), | ||
attributes => getAttributesWithoutSelector(attributes, selectorAttribute), | ||
cleanAttributes | ||
)(sourceNode) | ||
]) | ||
} | ||
/** | ||
* Create an attribute evaluation function | ||
@@ -471,0 +490,0 @@ * @param {RiotParser.Attr} sourceNode - riot parser node |
import composeSourcemaps from './utils/compose-sourcemaps' | ||
import { createOutput } from './transformer' | ||
import panic from './utils/panic' | ||
import {panic} from '@riotjs/util/misc' | ||
@@ -5,0 +5,0 @@ export const postprocessors = new Set() |
@@ -1,2 +0,2 @@ | ||
import panic from './utils/panic' | ||
import {panic} from '@riotjs/util/misc' | ||
import { transform } from './transformer' | ||
@@ -3,0 +3,0 @@ /** |
import asJSON from './sourcemap-as-json' | ||
import {composeSourceMaps} from 'recast/lib/util' | ||
import isNode from './is-node' | ||
import {isNode} from '@riotjs/util/checks' | ||
@@ -5,0 +5,0 @@ /** |
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
1499657
37990
15
48
+ Added@riotjs/util@1.1.0
+ Added@riotjs/util@1.1.0(transitive)
- Removed@riotjs/dom-bindings@^4.3.0
- Removed@riotjs/dom-bindings@4.8.3(transitive)
- Removed@riotjs/util@1.3.1(transitive)
- Removeddomdiff@2.2.2(transitive)
- Removeduarray@1.0.0(transitive)
Updated@riotjs/parser@^4.1.0