Conversation
|
To test, load a repository style in the Visual Editor from disk, change the value of "default-locale" under Global Formatting Options, and switch to the Code Editor. With this PR, "xmlns" no longer gets appended to the end of the attribute list on |
|
And if this can be simplified, I'm all ears. (for comparison, I put the "rel" attribute on |
|
I've seen this, and while I haven't tested it I'm convinced it will work, but am worried about performance. How often does this run? Only on save and switching to the code editor? |
|
The inner workings of the editor are a bit of a mystery to me, but I doubt performance is a concern here. The new code itself is rather light-weight, and I'm pretty sure it doesn't run often. |
I know that JavaScript object attributes officially don’t have an order, but I prefer to keep the xmlns attribute at the start of the style element, and this code works for me (in Chrome).
See citation-style-language/styles@33ab94f#diff-6a52dc4de6b126dc7e28e0902fe7f752 for an example of where we reorder this attribute with my Python script.
I got it to work by deep-cloning the object (http://stackoverflow.com/a/4591639/1712389), deleting all attributes except xmlns (http://stackoverflow.com/questions/19316857/removing-all-properties-from-a-object), and then repopulating the object with the deleted attributes.