Comparing version 5.2.4 to 5.2.5
@@ -5,3 +5,3 @@ { | ||
"license": "MIT", | ||
"version": "5.2.4", | ||
"version": "5.2.5", | ||
"type": "module", | ||
@@ -8,0 +8,0 @@ "types": "./types/index.d.ts", |
@@ -1,4 +0,5 @@ | ||
/** @import { ExportDefaultDeclaration, Node } from 'estree' */ | ||
/** @import { ExportDefaultDeclaration } from 'estree' */ | ||
/** @import { Context } from '../types' */ | ||
import * as e from '../../../errors.js'; | ||
import { validate_export } from './shared/utils.js'; | ||
@@ -10,3 +11,7 @@ /** | ||
export function ExportDefaultDeclaration(node, context) { | ||
if (context.state.ast_type === 'instance') { | ||
if (!context.state.ast_type /* .svelte.js module */) { | ||
if (node.declaration.type === 'Identifier') { | ||
validate_export(node, context.state.scope, node.declaration.name); | ||
} | ||
} else { | ||
e.module_illegal_default_export(node); | ||
@@ -13,0 +18,0 @@ } |
@@ -60,21 +60,3 @@ /** @import { ExportNamedDeclaration, Identifier, Node } from 'estree' */ | ||
} | ||
if (!context.state.ast_type /* .svelte.js module */ || context.state.ast_type === 'module') { | ||
for (const specified of node.specifiers) { | ||
if (specified.local.type !== 'Identifier') continue; | ||
const binding = context.state.scope.get(specified.local.name); | ||
if (!binding) continue; | ||
if (binding.kind === 'derived') { | ||
e.derived_invalid_export(node); | ||
} | ||
if ((binding.kind === 'state' || binding.kind === 'raw_state') && binding.reassigned) { | ||
e.state_invalid_export(node); | ||
} | ||
} | ||
} | ||
} | ||
} |
@@ -1,6 +0,4 @@ | ||
/** @import { ExportSpecifier, Node } from 'estree' */ | ||
/** @import { Binding } from '#compiler' */ | ||
/** @import { ExportSpecifier } from 'estree' */ | ||
/** @import { Context } from '../types' */ | ||
/** @import { Scope } from '../../scope' */ | ||
import * as e from '../../../errors.js'; | ||
import { validate_export } from './shared/utils.js'; | ||
@@ -33,20 +31,1 @@ /** | ||
} | ||
/** | ||
* | ||
* @param {Node} node | ||
* @param {Scope} scope | ||
* @param {string} name | ||
*/ | ||
function validate_export(node, scope, name) { | ||
const binding = scope.get(name); | ||
if (!binding) return; | ||
if (binding.kind === 'derived') { | ||
e.derived_invalid_export(node); | ||
} | ||
if ((binding.kind === 'state' || binding.kind === 'raw_state') && binding.reassigned) { | ||
e.state_invalid_export(node); | ||
} | ||
} |
/** @import { AST } from '#compiler' */ | ||
/** @import { Context } from '../types' */ | ||
import { is_mathml, is_svg, is_void } from '../../../../utils.js'; | ||
import { cannot_be_set_statically, is_mathml, is_svg, is_void } from '../../../../utils.js'; | ||
import { | ||
@@ -80,5 +80,3 @@ is_tag_valid_with_ancestor, | ||
node.attributes.some( | ||
(attribute) => | ||
attribute.type === 'Attribute' && | ||
(attribute.name === 'autofocus' || attribute.name === 'muted') | ||
(attribute) => attribute.type === 'Attribute' && cannot_be_set_statically(attribute.name) | ||
) | ||
@@ -85,0 +83,0 @@ ) { |
@@ -1,2 +0,2 @@ | ||
/** @import { AssignmentExpression, Expression, Literal, Pattern, PrivateIdentifier, Super, UpdateExpression, VariableDeclarator } from 'estree' */ | ||
/** @import { AssignmentExpression, Expression, Literal, Node, Pattern, PrivateIdentifier, Super, UpdateExpression, VariableDeclarator } from 'estree' */ | ||
/** @import { AST, Binding } from '#compiler' */ | ||
@@ -266,1 +266,20 @@ /** @import { AnalysisState, Context } from '../../types' */ | ||
} | ||
/** | ||
* Checks that the exported name is not a derived or reassigned state variable. | ||
* @param {Node} node | ||
* @param {Scope} scope | ||
* @param {string} name | ||
*/ | ||
export function validate_export(node, scope, name) { | ||
const binding = scope.get(name); | ||
if (!binding) return; | ||
if (binding.kind === 'derived') { | ||
e.derived_invalid_export(node); | ||
} | ||
if ((binding.kind === 'state' || binding.kind === 'raw_state') && binding.reassigned) { | ||
e.state_invalid_export(node); | ||
} | ||
} |
@@ -31,3 +31,3 @@ /** @import { ClassBody, Expression, Identifier, Literal, MethodDefinition, PrivateIdentifier, PropertyDefinition } from 'estree' */ | ||
if ( | ||
definition.type === 'PropertyDefinition' && | ||
(definition.type === 'PropertyDefinition' || definition.type === 'MethodDefinition') && | ||
(definition.key.type === 'Identifier' || | ||
@@ -34,0 +34,0 @@ definition.key.type === 'PrivateIdentifier' || |
@@ -8,2 +8,3 @@ /** @import { Expression, ExpressionStatement, Identifier, Literal, MemberExpression, ObjectExpression, Statement } from 'estree' */ | ||
import { | ||
cannot_be_set_statically, | ||
is_boolean_attribute, | ||
@@ -266,4 +267,3 @@ is_dom_property, | ||
!is_custom_element && | ||
attribute.name !== 'autofocus' && | ||
attribute.name !== 'muted' && | ||
!cannot_be_set_statically(attribute.name) && | ||
(attribute.value === true || is_text_attribute(attribute)) | ||
@@ -270,0 +270,0 @@ ) { |
@@ -6,2 +6,3 @@ /** @import { Expression } from 'estree' */ | ||
import { escape_html } from '../../../../../../escaping.js'; | ||
import { cannot_be_set_statically } from '../../../../../../utils.js'; | ||
import { is_event_attribute } from '../../../../../utils/ast.js'; | ||
@@ -146,3 +147,3 @@ import * as b from '../../../../../utils/builders.js'; | ||
if (attribute.name === 'autofocus' || attribute.name === 'muted') { | ||
if (cannot_be_set_statically(attribute.name)) { | ||
return false; | ||
@@ -149,0 +150,0 @@ } |
@@ -195,3 +195,4 @@ const regex_return_characters = /\r/g; | ||
playsinline: 'playsInline', | ||
readonly: 'readOnly' | ||
readonly: 'readOnly', | ||
srcobject: 'srcObject' | ||
}; | ||
@@ -216,3 +217,4 @@ | ||
'inert', | ||
'volume' | ||
'volume', | ||
'srcObject' | ||
]; | ||
@@ -227,3 +229,14 @@ | ||
const NON_STATIC_PROPERTIES = ['autofocus', 'muted']; | ||
/** | ||
* Returns `true` if the given attribute cannot be set through the template | ||
* string, i.e. needs some kind of JavaScript handling to work. | ||
* @param {string} name | ||
*/ | ||
export function cannot_be_set_statically(name) { | ||
return NON_STATIC_PROPERTIES.includes(name); | ||
} | ||
/** | ||
* Subset of delegated events which should be passive by default. | ||
@@ -230,0 +243,0 @@ * These two are already passive via browser defaults on window, document and body. |
@@ -9,3 +9,3 @@ // generated during release, do not modify | ||
*/ | ||
export const VERSION = '5.2.4'; | ||
export const VERSION = '5.2.5'; | ||
export const PUBLIC_VERSION = '5'; |
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
2337373
51523