Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New function _copyAttributes() #162

Closed
arvgta opened this issue Jan 9, 2019 · 5 comments
Closed

New function _copyAttributes() #162

arvgta opened this issue Jan 9, 2019 · 5 comments

Comments

@arvgta
Copy link
Owner

@arvgta arvgta commented Jan 9, 2019

A user reported an error being thrown by _copyAttributes()

@arvgta arvgta added the bug label Jan 9, 2019
@arvgta arvgta changed the title Bug in new function _copyAttributes() New function _copyAttributes() revealing error Jan 10, 2019
@arvgta arvgta added question and removed bug labels Jan 10, 2019
@arvgta arvgta changed the title New function _copyAttributes() revealing error New function _copyAttributes() revealing error in input data Jan 10, 2019
@arvgta arvgta closed this Jan 12, 2019
@arvgta arvgta reopened this Mar 25, 2019
@arvgta arvgta added the bug label Mar 25, 2019
@arvgta
Copy link
Owner Author

@arvgta arvgta commented Mar 25, 2019

Here is the salient code:

function _copyAttributes(el, $S, flush) { //copy all attributes of element generically
    if (flush) //delete all old attributes
        for (var i = el.attributes.length - 1; i >= 0; i--) el.removeAttribute(el.attributes[i].name);

    var attr, attributes = Array.prototype.slice.call($S[0].attributes); //slice performs a copy, too
    while (attr = attributes.pop()) { //fetch one of all the attributes at a time
        el.setAttribute(attr.nodeName, attr.nodeValue); //low-level insertion
    }
}

When appied to the handling of (a) content element(s) $S can contain no or faulty data...

Fixed by not applying _copyAttributes() to (a) content element(s) for the time being...

@Seerver
Copy link

@Seerver Seerver commented Mar 30, 2019

Hi, I wrote you an email.

arvgta added a commit that referenced this issue Apr 1, 2019
arvgta added a commit that referenced this issue Apr 24, 2019
No functional change, but getting rid of the nuissance described in issue #162
@arvgta arvgta changed the title New function _copyAttributes() revealing error in input data Problem with new function _copyAttributes() May 9, 2019
@arvgta arvgta changed the title Problem with new function _copyAttributes() Problem with new function _copyAttributes() - fixed May 9, 2019
@arvgta arvgta removed the question label May 9, 2019
@arvgta
Copy link
Owner Author

@arvgta arvgta commented May 11, 2019

Tested on the two usual sites:

... as well as two more Ajaxify user sites

...successfully...

thus closing

@arvgta arvgta closed this May 11, 2019
@arvgta arvgta changed the title Problem with new function _copyAttributes() - fixed New function _copyAttributes() - revisited Jun 7, 2019
@arvgta
Copy link
Owner Author

@arvgta arvgta commented Jun 7, 2019

Re-opening, because I would like to give the flush mechanism another try with this code:

if (flush) //delete all old attributes
    while(el.attributes.length > 0)
        el.removeAttribute(el.attributes[0].name);
@arvgta arvgta reopened this Jun 7, 2019
@arvgta arvgta added enhancement and removed bug labels Jun 21, 2019
@arvgta arvgta changed the title New function _copyAttributes() - revisited New function _copyAttributes() Jul 8, 2019
@arvgta
Copy link
Owner Author

@arvgta arvgta commented Jul 8, 2019

Once content elements consistency is validated beforehand as described in this issue, it seems that there are no more errors / warnings including such in the flush mechanism. However, if there is a more elegant (pure jQuery) style to handle the copying of attributes, then please let me know!

Closing...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants