Skip to content

Commit e7125f3

Browse files
committed
only apply skipped steps on unknown namespaces
1 parent a941cff commit e7125f3

File tree

3 files changed

+10
-11
lines changed

3 files changed

+10
-11
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"posttest": "agadoo internal/index.mjs",
3838
"prepublishOnly": "npm run lint && PUBLISH=true npm test",
3939
"tsd": "tsc -p src/compiler --emitDeclarationOnly && tsc -p src/runtime --emitDeclarationOnly",
40-
"lint": "eslint '{src,test}/**/*.{ts,js}'"
40+
"lint": "eslint \"{src,test}/**/*.{ts,js}\""
4141
},
4242
"repository": {
4343
"type": "git",

src/compiler/compile/render_dom/wrappers/Element/Attribute.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import Expression from '../../../nodes/shared/Expression';
88
import Text from '../../../nodes/Text';
99
import handle_select_value_binding from './handle_select_value_binding';
1010
import { Identifier, Node } from 'estree';
11-
import { namespaces, valid_namespaces } from '../../../../utils/namespaces';
11+
import { valid_namespaces } from '../../../../utils/namespaces';
1212

1313
export class BaseAttributeWrapper {
1414
node: Attribute;
@@ -68,13 +68,13 @@ export default class AttributeWrapper extends BaseAttributeWrapper {
6868
}
6969

7070
const namespace = this.parent.node.namespace;
71-
// some processing only applies to html namespace (and not MathML, SVG, or Svelte Native etc)
72-
if (namespace && namespace != 'html' && namespace != namespaces.html) {
73-
// attributes outside of the html namespace may be case sensitive
74-
// namespaces for which we don't have case corrections, are left in their original case (required for svelte-native)
75-
this.name = (valid_namespaces.indexOf(namespace) >= 0) ? fix_attribute_casing(this.node.name) : this.node.name;
71+
72+
// some processing only applies to known namespaces
73+
if (namespace && !valid_namespaces.includes(namespace)) {
74+
// attributes outside of the valid namespace may be case sensitive (eg svelte native). We leave them in their current case
75+
this.name = this.node.name;
76+
this.metadata = this.get_metadata();
7677
this.is_indirectly_bound_value = false;
77-
this.metadata = null;
7878
this.property_name = null;
7979
this.is_select_value_attribute = false;
8080
this.is_input_value = false;
@@ -92,7 +92,6 @@ export default class AttributeWrapper extends BaseAttributeWrapper {
9292

9393
this.is_src = this.name === 'src'; // TODO retire this exception in favour of https://github.com/sveltejs/svelte/issues/3750
9494
this.should_cache = should_cache(this);
95-
9695
}
9796

9897
render(block: Block) {

test/runtime/samples/attribute-casing-unknown-namespace/_config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export default {
1212

1313
test({ assert, target }) {
1414
const attr = sel => target.querySelector(sel).attributes[0].name;
15-
assert.equal(attr('page'), "horizontalAlignment");
16-
assert.equal(attr('button'), "textWrap");
15+
assert.equal(attr('page'), 'horizontalAlignment');
16+
assert.equal(attr('button'), 'textWrap');
1717
}
1818
};

0 commit comments

Comments
 (0)