Skip to content

Commit

Permalink
only apply skipped steps on unknown namespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
halfnelson committed Oct 1, 2020
1 parent a941cff commit e7125f3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"posttest": "agadoo internal/index.mjs",
"prepublishOnly": "npm run lint && PUBLISH=true npm test",
"tsd": "tsc -p src/compiler --emitDeclarationOnly && tsc -p src/runtime --emitDeclarationOnly",
"lint": "eslint '{src,test}/**/*.{ts,js}'"
"lint": "eslint \"{src,test}/**/*.{ts,js}\""
},
"repository": {
"type": "git",
Expand Down
15 changes: 7 additions & 8 deletions src/compiler/compile/render_dom/wrappers/Element/Attribute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import Expression from '../../../nodes/shared/Expression';
import Text from '../../../nodes/Text';
import handle_select_value_binding from './handle_select_value_binding';
import { Identifier, Node } from 'estree';
import { namespaces, valid_namespaces } from '../../../../utils/namespaces';
import { valid_namespaces } from '../../../../utils/namespaces';

export class BaseAttributeWrapper {
node: Attribute;
Expand Down Expand Up @@ -68,13 +68,13 @@ export default class AttributeWrapper extends BaseAttributeWrapper {
}

const namespace = this.parent.node.namespace;
// some processing only applies to html namespace (and not MathML, SVG, or Svelte Native etc)
if (namespace && namespace != 'html' && namespace != namespaces.html) {
// attributes outside of the html namespace may be case sensitive
// namespaces for which we don't have case corrections, are left in their original case (required for svelte-native)
this.name = (valid_namespaces.indexOf(namespace) >= 0) ? fix_attribute_casing(this.node.name) : this.node.name;

// some processing only applies to known namespaces
if (namespace && !valid_namespaces.includes(namespace)) {
// attributes outside of the valid namespace may be case sensitive (eg svelte native). We leave them in their current case
this.name = this.node.name;
this.metadata = this.get_metadata();
this.is_indirectly_bound_value = false;
this.metadata = null;
this.property_name = null;
this.is_select_value_attribute = false;
this.is_input_value = false;
Expand All @@ -92,7 +92,6 @@ export default class AttributeWrapper extends BaseAttributeWrapper {

this.is_src = this.name === 'src'; // TODO retire this exception in favour of https://github.com/sveltejs/svelte/issues/3750
this.should_cache = should_cache(this);

}

render(block: Block) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default {

test({ assert, target }) {
const attr = sel => target.querySelector(sel).attributes[0].name;
assert.equal(attr('page'), "horizontalAlignment");
assert.equal(attr('button'), "textWrap");
assert.equal(attr('page'), 'horizontalAlignment');
assert.equal(attr('button'), 'textWrap');
}
};

0 comments on commit e7125f3

Please sign in to comment.