Comments (4)
The new behaviour is the right behaviour, and also how browsers behave.
When you create an element in a namespace, it doesn't add an xmlns attribute into the document tree. Therefore, getAttribute('xmlns')
returns NULL. The serializer invoked via saveXML()
adds an xmlns attribute in its string output such that the namespace is preserved when parsing the output. However, the attribute is still not added in the document tree.
When you now reload the document by parsing the output from saveXML()
, the attribute will be added to the document tree because the input string had the attribute.
You can check this is the same what your browser does:
doc = document.implementation.createDocument('', '');
doc.appendChild(doc.createElementNS('http://www.w3.org/2000/svg', 'svg'));
console.log(doc.firstChild.getAttribute('xmlns')) // returns null
console.log( (new XMLSerializer).serializeToString(doc) ) // now it adds the xmlns attribute in the output, but it still doesn't exist in the document
The "old DOM" behaviour is wrong: it mixes the concept of an internally defined namespaces with attributes that are observable.
I’d have expected that serializing and parsing produces an identical state of the document, but it didn’t.
There are multiple cases where the use of namespaces can lead to invalid XML, and so there are rules that are laid out by the spec on how to make the serializer resolve these issues.
from php-src.
BTW If your intention is to get the default namespace in a certain context node, you can use lookupNamespaceURI
.
from php-src.
Makes sense. Next time I will cross check with the browser behavior in advance.
☺️
FTR: I don't mind answering questions if anything is unclear or seems off though. :-)
from php-src.
Thank you for the detailed explanation!
You can check this is the same what your browser does
Makes sense. Next time I will cross check with the browser behavior in advance.
from php-src.
Related Issues (20)
- Add "abstract constant" support
- PDO PostreSQL - parser is broken for `'...\'` HOT 15
- Issue with ob handler context and execution in PHP HOT 5
- Anonymous classes with dynamic parent class HOT 7
- Build failed at mbstring_arginfo.h on Windows(Visual C++) with --enable-mbregex
- Incorrect validation of #[\Attribute]’s first parameter HOT 2
- better error message for when upload_max_filesize is exceeded HOT 1
- DateInterval cannot parse decimal fraction in ISO duration string
- Fuzzer readme still mentions obsolete --enable-json flag
- Maintain a docker tag for nightly master build HOT 7
- Heap Buffer Overflow in sqlite extension HOT 2
- Storing DOMElement consume 4 times more memory in PHP 8.1 than in PHP 8.0 HOT 3
- PHP checks the filesystem for file existing even if available in opcache and all opcache validations are disabled HOT 21
- binary diff generated for arginfo.h HOT 8
- Objects implementing ArrayAccess cannot discern appended values or setting a value with a NULL offset. HOT 2
- Include JS WebCrypto raw format for openssl_get_publicKey
- Add new method: array_find HOT 10
- Member access within misaligned address in zend_alloc.c HOT 1
- Segmentation fault: some combination of array operations, first-class callable, exception handler and autoloader HOT 2
- password_hash does not allow \0 in the $password HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from php-src.