Failed to execute 'createElement' on 'Document': The result must not have children - custom-element

I've been using custom elements v1 for a while now via a polyfill. Chrome 54 (the first version with a native v1 implementation) started throwing errors when initializing my elements:
DOMException: Failed to execute 'createElement' on 'Document': The result must not have children
The offending line is a simple:
let el = document.createElement('my-custom-element');

Chrome's native implementation appears to be enforcing specification requirements that the polyfill was not. According to the "Requirements for custom element constructors" section of the spec:
The element must not gain any attributes or children, as this violates the expectations of consumers who use the createElement or createElementNS methods.
The element that I was attempting to create added children to itself in its constructor.
The solution was to follow the recommendations of the spec:
In general, work should be deferred to connectedCallback as much as possible—especially work involving fetching resources or rendering. However, note that connectedCallback can be called more than once, so any initialization work that is truly one-time will need a guard to prevent it from running twice.
That is, add children in the connected callback and use a flag to ensure the element is only initialized on first connection.

Related

control moto's state transitions of EC2 instances?

To test that my application handles state transitions correctly, I'd like control over the lifecycle of moto's fake EC2 instances:
Rather than have instances start immediately in running, it would be nice to have them start in pending, let me confirm some things, and then explicitly transition them to running.
Relatedly, there are some actions I'd like to trigger in my tests when the instances switch to running.
Is any of this possible? I found InstanceBackend in moto's code -- is there a way for users to hook into or override methods there?
There are a few feature requests for more control over the transition cycle, but nothing has been implemented yet.
It is possible to use the internal API to set the status directly, as you said, using the InstanceBackend.
If you only have one instance, you can use the following code:
ec2_backend = moto.ec2.models.ec2_backends[my-region]
list(ec2_backend.reservations.values())[0].instances[0].state = "..."
If you have multiple reservations, you can use the reservation ID like this:
ec2_backend.reservations["r-7df1884b"].instances[0].state = "..."
Note that both AWS and Moto use two properties to track state, state and state_code. Only updating state may result in undefined behaviour, so you may want to update both to ensure they are in sync:
ec2_backend.reservations["r-7df1884b"].instances[0].state_code = ..
Note that this is an internal API, so changes to this data structure may occur without warning.

Should I assert for existing before assertion for Selector property?

Documentation states that "When a selector is executed, TestCafe waits for the target node to appear in the DOM until the selector timeout expires." and we don't use expect(Selector.exists).ok() in code sample below the statement. However in another paragraph we see that the Smart Assertion Query Mechanism does not wait for page elements to appear. If you need to wait for an element before executing an assertion, add another assertion that checks the selector’s count or exists property. and in code we see the .exist assertion (.expect(nameInput.exists).ok());
My question is: should I check for existence of an element of I can use assertions like expect(elementSelector[anyProperty]) without this pre-check?
No, you shouldn't check whether an element exists. I agree that the documentation indeed may be confusing. We have created an issue regarding this question:

Assert Failed ipv4-l3-protocol.cc

When running a simulation for a channel assignment algorithm in mesh network in NS3.25 I get the following error:
assert failed. cond="tc != 0", file=..src/internet/model/ipv4-l3-protocol.cc
terminate called without an active exception
I have tried the simulation with different parameter settings. However, I still get the same error. I cant figure out its cause, or what should I try to eliminate it.
Seems to me, just looking at the variable names, that you're missing Traffic Control (tc) layer in the node, since assertion fails. Have you initialized your IPv4 stack on the node using InternetStackHelper?
It sets a simple FIFO TC layer by default if none other is provided. If you initialized your stack manually, without using the helper, that may be the problem.

Relay modern caching example

I would like to enable caching in my react native application. I am using GraphQL with Relay modern. I found out that caching is not enabled by default in relay modern, but they have exposed RelayQueryResponseCache from relay-runtime, which we can add to the fetchQuery function in our API. I read discussion here and here about it, but have not seen any example to get started. Can someone help me out on this?
EDIT:
Ok I came up with a solution. I think it misses few things but so far it serves our needs.
I have noticed that passing anything into QueryRenderer into cacheConfig results passing that value into fetchQuery function inside my environment.
So I have created a Component which loads the data by some relation and resolves it into the correct json structure requested by the query. Then I return this into the state. Then I extended my Component which contains QueryRenderer with the created 'cache loader'. Now when componentWillMount() is called I ask for the cached data. During this I have set this.state.loading = true so I am able to handle loading state. Reading from DB is async.
I am using this class in other components as well. Every one handles its cache data. I just pass it to QueryRenderer.
However I was thinking that this makes some extra logic need to add for each Component which is supported by this caching. Probably passing the cache resolver as cacheConfig and resolve the cached data immediately inside the environment would be much more cleaner.

jsReport - Timeout error when passing data to child template

We are using the jsReport HTML reporting engine. We are using the cloud-based system at jsreportonline.net.
I am unable to get a child report to populate.
Please have a look to this link:-
https://playground.jsreport.net/studio/workspace/rkYn7WaCg/100
Subreports are an advertised feature of jsReport, but we are unable to get a child template to render.
Anyone have success with child templates? Is there an error in how I am attempting to utilize this feature?
The best practice when troubleshooting any kind problem in software development - try to isolate it.
Don't complain child templates timeout when you have a lot of other complexity around. Some scripts maps and other elements. Do you get the timeout when running html recipe? You would get much closer to the real problem and potentially solve it on your own before posting your question on the internet over and over. You just take our time to save yours.
Switching the phantom recipe to html shows no timeout. The timeout is likely caused because your custom printing trigger is not fired.
Your child template syntax is additionally not valid
{#child childtemplate #data={{{toJSON this}}} }
At this point you cannot pass handlebars context to the child template. You have only the option to pass custom parameter, like array index through #data.paramA=val additionally to the original data.
See the docs
https://jsreport.net/learn/child-templates