Skip to content

Commit

Permalink
Fixed namespace creation on '<namespace>:<name>' tag names
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrienCastex committed May 20, 2017
1 parent 3fbfb17 commit 76d8bb0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion lib/helper/XML.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ var XML = (function () {
XML.createElement = function (name, attributes, text) {
if (!attributes)
attributes = {};
var lindex = Math.max(name.lastIndexOf(':'), name.lastIndexOf('/')) + 1;
var li1 = name.lastIndexOf(':');
var li2 = name.indexOf(':');
var lindex = Math.max(li1 === li2 ? -1 : li2, name.lastIndexOf('/')) + 1;
if (lindex !== 0) {
attributes['xmlns:x'] = name.substring(0, lindex);
name = 'x:' + name.substring(lindex);
Expand Down
4 changes: 3 additions & 1 deletion src/helper/XML.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,9 @@ export abstract class XML
if(!attributes)
attributes = {};

const lindex = Math.max(name.lastIndexOf(':'), name.lastIndexOf('/')) + 1;
const li1 = name.lastIndexOf(':');
const li2 = name.indexOf(':');
const lindex = Math.max(li1 === li2 ? -1 : li2, name.lastIndexOf('/')) + 1;
if(lindex !== 0)
{
attributes['xmlns:x'] = name.substring(0, lindex);
Expand Down

0 comments on commit 76d8bb0

Please sign in to comment.