7.3.1 - Stylin And Classy
- 7.3.1 - Nov 21 2017
-
Update str(AdvancedTag) to give the real HTML representation (start tag,
inner html, and end tag) versus the former implementation which was: joined direct-child text nodes only </ end tag>The old method is still available as old__str_, and you can revert to old
behaviour (why would you want to?) by doing AdvancedTag.str =
AdvancedTag.old__str_ -
Add toHTML/getHTML/asHTML methods to AdvancedTag which also return an HTML
document starting at that node -
Minor updates to READMEs
-
Measurable performance improvements, especially in tags
-
Improve removeAttribute / del tag.attributes['whatever'] to perform the
special handling / linkage required when dealing with the "style" or "class" attribute -
Merge in latest distrib/runTests.py from GoodTests, which among improvements for installation / ensuring GoodTests.py is present, now it is supported to easily test python2 vs python3 just by invoking runTests.py with one or the other (i.e. if you run "python2 ./runTests.py" you'll execute the test suite in python2, vs "python3 ./runTests.py" executes in python3). Previously to do this reliably you'd have to use virtualenvs.
-
AdvancedTag.classList now returns a COPY, so changes don't flow back to the associated tag (just like in JS api).
-
Unify tag classes to be stored in a single location ( private _classNames list), and wherever used it is generated from that. Prior it was stored as a string in the attributes dict, and in the _classNames list. This caused strangeness and opened the potential for disconnects. I don't much care for this hacked impl, as 'class' needs to show up or be absent from attributes, as well as work with setAttribute, removeAttribute, it is hacked on via interception. Also, digs a slightly deeper hole for attributes to be standalone (already requires a tag to work properly). Hopefully I can come up with a better impl soon, but this at least meets the goals.
-
Fix nextSibling and nextSiblingElement which would throw an exception (instead of return None) when called on the last element in a set of peers. Also fix the typo in the tests which would have caught this but was preventing them from running.
-
Remove stray pdb.set_trace() which was live in the .find method (Alternative for ORM-style filtering without having QueryableList dependency installed)
-
Fixup addClass / removeClass and anywhere else the class/className attribute can be inserted or modified, and ensure we properly strip the value (all leading and tailing whitespace, and reduce any in-between-words whitespace to a single space)
-
Allow addClass/removeClass to handle adding and removing multiple, like tag.addClass('classOne classTwo') would add both classOne and classTwo
-
Ensure that the "style" attribute is always linked between the tag and attributes, and that calling .setAttribute('style', '') for example doesn't leave an empty "style" attribute in html representation
-
Many additional unit tests
- 7.3.0 - Nov 19 2017
-
Lots of fixups to "style" property:
- Properly handle that "style" tag wouldn't show up in HTML if tag
created without one, and only the form "myTag.style.someProperty =
'value'" was used. - Fix where empty style="" would be on HTML if all the values removed
via dot-access - Fix where we weren't doing a copy with "tag1.style = tag2.style", and
thus any changes to either style would affect both tags - Fix issue where setting style to empty string twice would cause it to
lose the special StyleAttribute type - Some performance improvements when dealing with style
- Add "isEmpty" method to check if a style is empty (has no values
set). For now we do a dict comparison between the two styles (or
convert a string to a StyleAttribute map and then perform the test)
whereas Javascript does an identity comparison (so even the same style
on different tags don't equal eachother, and with tag1.style =
"font-weight:bold", tag1.style == "font-weight: bold" would be False in
javascript but we return True. This may change in the future - Update the "equals" on a style to be able to compare against a string
(see note above how this differs from the javascript ABI), so
myTag.style == "display: block" will now work as expected. - Fix issue where assigning a tag's style to itself would cause a
disconnect with the HTML attribute value, i.e. myTag.style =
myTag.style - Properly handle other misc. situations with style that were being
handled wrong before - Ensure we always link the HTML-displayed attribute to the underlying
style object attribute - Add several more tests to style, many of which fail on 7.2 but now
pass with these changes - When removing a style from a tag ( like myTag.style = somethingElse ), make sure we remove the association
between the old style and the tag to prevent updates on the old style from affecting the former tag - Add some comments to the style section
- Add "setProperty" method per JS api, which is a function call to set
(name, value) for a style property, or provide value='' or value=null to
remove that property
- Properly handle that "style" tag wouldn't show up in HTML if tag
-
Addition of a lot of comments throughout code
-
Change the "style" (StyleAttribute) attribute's backref on a tag to that tag into a weak
reference, which removes a circular reference. -
Change the "_attribute" ( SpecialAttributesDict ) attribute's backref on a tag to that tag into a weak
reference, which removes a circular reference. -
Additions and modification to pydoc documentation
-
Minor cleanups / improvements